query
TanStack Query is an async state management library for fetching, caching, synchronizing, and updating server state in web apps. It abstracts the lifecycle of asynchronous data with declarative queries and mutations, supporting any data source (REST, GraphQL, promises) across React, Vue, Svelte, Solid, and Angular.
MITPermissive — free to use in commercial and proprietary software, with attribution.View license →
Production readiness
4/5- Actively maintainedCommits in the last 6 months
- No known vulnerabilitiesNot yet scanned
- Clear, usable licenseMIT (permissive)
- Proven adoptionWidely used
- Has documentationDocumentation indexed
npm install queryOur analysis
A framework-agnostic library that manages server state — the cache layer between your UI and remote data — handling fetching, caching, deduplication, background refetching, and mutations declaratively.
When to use query
Reach for it when your app fetches remote data and you're tired of hand-rolling loading/error states, cache invalidation, refetch-on-focus, and request deduplication. Excellent for REST or GraphQL apps, dashboards with frequently changing data, infinite/paginated lists, and optimistic UI updates.
When not to
It is not a client-state manager — for purely local UI state use Zustand, Jotai, or Redux. If you already use a normalized GraphQL cache (Apollo/Relay) and rely on entity normalization, Query's key-based cache may feel less powerful. Overkill for apps with minimal data fetching.
Strengths
- Drastically reduces boilerplate around loading, error, and cache states
- Smart defaults: dedup, stale-while-revalidate, refetch on window focus/reconnect
- Protocol-agnostic — works with any promise-returning function
- First-class TypeScript inference and strong devtools
- Adapters for React, Vue, Solid, Svelte, and Angular
Trade-offs
- Key-based cache without normalization means related entities can fall out of sync without manual invalidation
- Learning curve around query keys, staleTime vs cacheTime, and invalidation strategies
- Adds a dependency and conceptual layer that can be unnecessary for simple apps
- Doesn't handle client/UI state, so larger apps still need a separate solution
Maturity
Very mature and widely adopted (~50k stars), actively maintained as part of the well-funded TanStack ecosystem with frequent releases, broad framework support, and production use at scale.
Become a Sponsor!
TanStack Query
An async state management library built to simplify fetching, caching, synchronizing, and updating server state.
Protocol‑agnostic fetching (REST, GraphQL, promises, etc.)
Caching, refetching, pagination & infinite scroll
Mutations, dependent queries & background updates
Prefetching, cancellation & React Suspense support
Read the docs →
Get Involved
We welcome issues and pull requests!
Participate in GitHub discussions
Chat with the community on Discord
See CONTRIBUTING.md for setup instructions
Partners
Explore the TanStack Ecosystem
TanStack Config – Tooling for JS/TS packages
TanStack DB – Reactive sync client store
TanStack DevTools – Unified devtools panel
TanStack Form – Type‑safe form state
TanStack Pacer – Debouncing, throttling, batching
TanStack Query – Async state & caching
TanStack Ranger – Range & slider primitives
TanStack Router – Type‑safe routing, caching & URL state
TanStack Start – Full‑stack SSR & streaming
TanStack Store – Reactive data store
TanStack Table – Headless datagrids
TanStack Virtual – Virtualized rendering
… and more at TanStack.com »