compositions/router-query
Installation
SKILL.md
TanStack Router + TanStack Query Integration
This skill requires familiarity with both TanStack Router and TanStack Query. Read router-core and react-router first.
This skill covers coordinating TanStack Query as an external data cache with TanStack Router's loader system. The router acts as a coordinator — it triggers data fetching during navigation, while Query manages caching, background refetching, and data lifecycle.
CRITICAL: Set
defaultPreloadStaleTime: 0when using TanStack Query. Without this, Router's built-in preload cache (30s default) prevents Query from controlling data freshness.
CRITICAL: For SSR, create
QueryClientinside thecreateRouterfactory function. A module-level singleton leaks data between server requests.