What problem does it solve?
Prevents conflicting caches, loading waterfalls, and broken SSR hydration when using TanStack Query alongside TanStack Router and TanStack Start by establishing a single source of truth and predictable data flow across loaders, components, and server renders.
Core Features & Use Cases
- Pass a per-request QueryClient through the router context to enable SSR-safe caching and type-safe access in loaders and hooks.
- Use loaders that call ensureQueryData so navigation preloads data into Query's cache and components can rely on useSuspenseQuery without loading waterfalls.
- Configure the router with defaultPreloadStaleTime set to 0 and use setupRouterSsrQueryIntegration to automate dehydration, hydration, streaming support, and redirect handling.
- Coordinate mutations and invalidation patterns so optimistic updates, background refetches, and cross-route cache sharing behave consistently.
Quick Start
Create a per-request QueryClient, pass it in the router context, call setupRouterSsrQueryIntegration, and use loaders with ensureQueryData to hydrate the Query cache before rendering.