ssr-data-fetching

Enable SSR-first data fetching and hydration for Next.js apps with TanStack Query v5.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/madlado87/agentes --skill ssr-data-fetching-madlado87
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ssr-data-fetching
Source: https://github.com/madlado87/agentes/tree/main/.github/skills/ssr-data-fetching
Command: npx skills add https://github.com/madlado87/agentes --skill ssr-data-fetching-madlado87

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

SSR-first data fetching with TanStack Query v5 enables server prefetch and client hydration, ensuring pages render with data on first paint and reduce perceived latency.

Core Features & Use Cases

  • Server prefetch and client hydration using TanStack Query v5 to provide fully rendered pages on first load.
  • Consistent hydration by enforcing identical query keys between server prefetch functions and client hooks.
  • Hydration pattern using HydrationBoundary and server/client API clients to streamline Next.js data flows.
  • Use Case: Build data-intensive dashboards that must render with data without loading spinners on initial render.

Quick Start

Run prefetchTasks() on the server and wrap your page with Hydrate to hydrate data on the client.

Frequently Asked Questions about ssr-data-fetching

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prefetch data in Next.js server components and hydrate it with TanStack Query v5?

To prefetch data in Next.js server components and hydrate it with TanStack Query, run server-side prefetch functions and wrap your page with HydrationBoundary to pass the dehydrated state to client hooks for seamless hydration.

Why does my TanStack Query hydration mismatch occur between server and client in Next.js?

TanStack Query hydration mismatches occur when server prefetch and client hooks use inconsistent query keys. Enforcing identical query keys between your server prefetch functions and client components ensures consistent hydration.

Can I validate API responses during SSR data fetching in Next.js?

Yes, you can validate API responses during SSR data fetching by applying zod schemas within your server and client API client wiring to ensure type safety before hydrating the data on the client.

What is the best way to prevent loading spinners on initial render for data-intensive Next.js dashboards?

The best way to prevent loading spinners on initial render is using SSR-first data fetching with server prefetch and HydrationBoundary, ensuring pages render fully with data on first paint and reduce perceived latency.

Does this SSR data fetching approach work with Next.js page routes and server components?

Yes, this SSR data fetching approach explicitly supports Next.js server components, page routes, and client components that rely on pre-fetched data, hydration consistency, and API client wiring.