tanstack-integration-best-practices

Coordinate TanStack Query, Router, and Start SSR patterns for consistent data flow and caching.

Updated Apr 14, 2026
One-click install
npx skills add https://github.com/iEnergyy/opsflow --skill tanstack-integration-best-practices-ienergyy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-integration-best-practices
Source: https://github.com/iEnergyy/opsflow/tree/main/.agents/skills/tanstack-integration-best-practices
Command: npx skills add https://github.com/iEnergyy/opsflow --skill tanstack-integration-best-practices-ienergyy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cross-layer data flow and caching challenges in TanStack-based apps, including SSR hydration, data prefetching, and router-query coordination.

Core Features & Use Cases

  • Consolidated best practices for integrating TanStack Query, Router, and Start across full-stack apps.
  • Guidance for setup, data flow, SSR hydration, and caching coordination in typical navigation scenarios.
  • Real-world use case: coordinating loader data with query caches to ensure instant UI with SSR-safe hydration.

Quick Start

Create a per-request QueryClient and wire SSR hydration using the recommended router integration.

Frequently Asked Questions about tanstack-integration-best-practices

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

FAQPage Schema
How do I coordinate TanStack Router and React Query for SSR data prefetching?

To coordinate TanStack Router and React Query for SSR data prefetching, wire loader-based data prefetching directly into route definitions. This ensures router loaders populate the query cache before SSR hydration, enabling instant UI delivery.

Why does my TanStack Start app have hydration mismatches during route navigation?

Hydration mismatches during route navigation in TanStack Start occur when server-side fetched data and client-side query caches are not aligned. You must enforce coordinated caching and automatic SSR dehydration/hydration rules to ensure consistent data flow.

What is the best way to set up a per-request QueryClient in a TanStack Start project?

The best way to set up a per-request QueryClient in a TanStack Start project is to instantiate a fresh QueryClient for each server request. This isolates user data and correctly wires SSR hydration using the recommended router integration.

How does SSR dehydration and hydration work across route navigations in TanStack apps?

SSR dehydration and hydration across route navigations in TanStack apps works by serializing the server-side query cache and sending it with the HTML payload. The client then hydrates this cache to prevent redundant fetches and maintain instant UI states.

Can I use loader-based data prefetch to automatically update TanStack Query caches?

Yes, you can use loader-based data prefetch to automatically update TanStack Query caches. By coordinating loader data with query caches, the router integration ensures prefetched data is immediately available for SSR-safe hydration without duplicate requests.

Do I need to manually invalidate cache when integrating TanStack Router and React Query?

While basic navigation relies on loader-based prefetch, you need to enforce coordinated caching and invalidation rules to maintain data consistency. This prevents stale data across full-stack TanStack apps by synchronizing router state with query invalidation triggers.