What problem does it solve?
TanStack Query solves the pain of manual, error-prone server data fetching by providing a consistent way to cache, refetch, and keep UI synchronized with remote data.
Core Features & Use Cases
- Server-state caching and stale-while-revalidate: Reuse previously fetched data instantly while refetching in the background to keep views up to date.
- Queries and mutations with lifecycle states: Manage loading/error/success states for both reads and writes, including retries and cancellation.
- Cache orchestration for real apps: Coordinate invalidation, optimistic updates, and pagination/infinite loading patterns for responsive UX.
Example use case: when a user edits a record, update the UI immediately with an optimistic mutation, then invalidate the relevant query keys to ensure the final cached data matches the server.
Quick Start
Use the tanstack-query skill to fetch and cache the current user profile for a given userId in a React component using a queryKey and queryFn.