What problem does it solve?
TanStack Query 5 removes the complexity of coordinating server-state fetching, caching, invalidation, and UI loading/error states so your React app behaves consistently across navigation, refetches, SSR hydration, and optimistic updates.
Core Features & Use Cases
- Query key factories & cache identity: prevents stale-data bugs by ensuring hierarchical, variable-inclusive query keys and safe invalidation.
- Queries, mutations, and infinite pagination: use
useQuery, useMutation, useInfiniteQuery, and useSuspenseQuery to cover standard, paginated, and Suspense-first data flows.
- Optimistic updates with rollback: implement production-safe patterns using
onMutate, cancelQueries, setQueryData, and onError/onSettled reconciliation.
- SSR prefetching for Next.js App Router: dehydrate/hydrate via
HydrationBoundary to avoid loading flashes and refetch waterfalls, with guardrails around staleTime mismatches.
Quick Start
Use the tanstack-query skill to set up a TanStack Query 5 data layer using a query key factory and a production QueryClient baseline, then implement useQuery/useMutation with correct staleTime, gcTime, and optimistic rollback where needed.