TanStack Query
Server state management library for React (and Vue, Solid, Svelte, Angular). Smart caching, automatic refetch, mutations with invalidation, Suspense, infinite scroll. ~50k GitHub stars, ~12M npm weekly downloads. v5 stable, ~13KB gzip.
Strengths
- Smart cache with automatic refetch on focus, network reconnect, and mount
- Mutations with full lifecycle: onMutate, onSuccess, onError, onSettled + auto invalidation
- Stable Suspense in v5: useSuspenseQuery eliminates manual loading states
- DevTools rebuilt in v5, inline cache editing, framework-agnostic
Limitations
- 13KB gzip, heavier than SWR (4KB) for simple use cases
- Learning curve on query keys, staleTime, gcTime for beginners
- No normalized cache, Apollo Client remains better for pure GraphQL
Best for
- React apps with REST/tRPC data fetching and complex mutations
- Replacing useEffect + useState patterns for server state
- Multi-framework apps (React → Vue migration) thanks to agnostic core