TanStack Query

Hooks-based async state management for fetching, caching, and syncing server data in React.

Library
npm
v5.101.4
50,161stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
92/100Excellent
Development Activity100
Maintenance100
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
92/100Excellent
Architecture93
Code Quality91
Innovation92
Learning Curve93

TanStack Query (formerly React Query) treats data from a server as a fundamentally different problem from client-side UI state: it’s asynchronous, owned by something outside your app, and can go stale the moment you fetch it. Rather than manually wiring loading flags, error state, and cache invalidation into a general-purpose store, TanStack Query gives every query a key, caches the result, and keeps it fresh with configurable staleness windows, background refetching, and automatic retries — so most apps stop hand-rolling this logic entirely.

@tanstack/react-query is the official React binding and by far the most widely used entry point into the project: it wraps the framework-agnostic @tanstack/query-core engine in hooks like useQuery, useMutation, and useInfiniteQuery, with first-class support for Suspense, SSR/RSC hydration in Next.js, and optimistic updates. The same core also ships adapters for Vue, Svelte, Solid, and Angular, plus an official DevTools panel and persistence plugins for offline-first caching.

What You Get

  • useQuery / useSuspenseQuery hooks with automatic caching, request deduplication, and background refetch-on-focus or reconnect
  • useMutation for create/update/delete flows, with onMutate/onError hooks for optimistic UI updates and automatic rollback
  • useInfiniteQuery and useSuspenseInfiniteQuery for cursor- or offset-based pagination and infinite-scroll lists
  • A configurable QueryClient controlling staleTime, gcTime, retry/backoff behavior, and global query defaults
  • React Query Devtools for inspecting cache contents, query status, and stale/fresh timers in real time
  • SSR and React Server Component support via HydrationBoundary and server-side prefetch helpers for Next.js and Remix
  • Persistence adapters (@tanstack/react-query-persist-client) for restoring the cache from localStorage or IndexedDB across page loads

Common Use Cases

  • Fetching REST or GraphQL data in a dashboard that needs to stay fresh via refetch-on-window-focus without manual polling code
  • Building paginated or infinite-scroll feeds where prior pages must stay cached while new ones load
  • Applying optimistic UI updates for likes, edits, or reorders that roll back automatically if the mutation fails
  • Prefetching and hydrating server state in a Next.js App Router route so the client never re-fetches data the server already has
  • Sharing one in-flight request across many components that ask for the same query key at the same time

Under The Hood

Architecture@tanstack/react-query is a thin binding: useBaseQuery (in packages/react-query/src/useBaseQuery.ts) reads and subscribes to a Query instance held in a framework-agnostic QueryCache via React’s useSyncExternalStore, delegating all fetching, retry, and staleness logic to @tanstack/query-core. Inside core, Query (query.ts) is a small reducer-based state machine — a private #dispatch method runs a switch-statement reducer over actions like fetch, success, failed, and invalidate to produce the next QueryState — built on a shared Subscribable base class that also underlies QueryObserver, QueryClient, and the mutation equivalents. This same core is what lets the Vue, Svelte, Solid, and Angular adapters exist as separate packages with almost no duplicated logic.

Tech Stack — The whole project is TypeScript in an Nx-managed pnpm monorepo (packages/query-core, packages/react-query, plus adapters for five other frameworks and framework-specific devtools/persist-client packages). Builds run through tsup to dual ESM/CJS output, publint and @arethetypeswrong/cli validate published package correctness, size-limit enforces bundle-size budgets, and changesets drives independent per-package versioning and the GitHub-Actions release pipeline.

Code Qualityquery-core and react-query alone carry 60+ Vitest test files (src/__tests__) covering the reducer transitions, retry/backoff timing, and hook behavior under Suspense and StrictMode; ESLint runs with a project-specific @tanstack/eslint-config plus the package’s own published eslint-plugin-query (used to lint query-key usage in consumer codebases too). Error handling is explicit throughout the reducer — failed fetches produce a typed error/fetchFailureReason on state rather than throwing past callers unless throwOnError is set.

API Design — The hook surface is deliberately small: useQuery({ queryKey, queryFn }) is enough to get caching, retries, and refetch-on-focus with zero configuration, and the same options object shape carries through useInfiniteQuery, useMutation, and the Suspense variants so switching between them is a rename, not a rewrite. The steeper part of the learning curve is conceptual rather than syntactic — understanding staleTime vs gcTime, and structuring query keys for correct invalidation — which the docs address directly with a dedicated “Important Defaults” and query-key guide.

Used by 161 apps in this directory

TypeScript
76%
AGPL 3.0

Abby

Developer Tools · Product Management

167

Statically typed feature flags, remote config, and A/B testing with framework-native SDKs for TypeScript teams.

View details
30
Repo Health
70
Technical
63
Dependency
Built with
TypeScript76%
MDX18%
Updated 1 years ago
TypeScript
99%
Other

Activepieces

Automation · AI Assistants

23,887

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
65
Dependency
Built with
TypeScript99%
Updated today
TypeScript
94%
MIT

Actual

Invoicing Finance

28,224

Local-first personal finance with envelope budgeting, end-to-end encryption, and multi-device sync — no subscription required.

View details
93
Repo Health
85
Technical
77
Dependency
Built with
TypeScript94%
Updated yesterday
Python
66%
Apache 2.0

Agent Control

AI Agents

295

An open-source runtime control plane for AI agents — define safety guardrails once, apply them across agents built on LangChain, CrewAI, Google ADK, or AWS Strands, and update controls without redeploying code.

View details
79
Repo Health
71
Technical
70
Dependency
Built with
Python66%
TypeScript33%
Updated yesterday
TypeScript
59%
Other

agenta

Developer Tools · Devops · AI Development

4,489

The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
TypeScript59%
Python39%
Updated today
Rust
64%
Apache 2.0

agentgateway

AI Development · Developer Tools

4,420

An open source AI-native proxy that secures, observes, and governs agent-to-LLM, agent-to-tool, and agent-to-agent communication through MCP, A2A, and unified LLM routing.

View details
88
Repo Health
82
Technical
72
Dependency
Built with
Rust64%
Go24%
Updated yesterday
TypeScript
100%
Apache 2.0

agentic-inbox

AI Agents · Productivity

6,880

A self-hosted email client with an AI agent that reads your inbox, drafts replies automatically, and exposes full email operations over MCP — running entirely on Cloudflare Workers.

View details
32
Repo Health
74
Technical
77
Dependency
Built with
TypeScript100%
Updated 3 months ago
TypeScript
86%
MIT

Agents Observe

Developer Tools

652

A real-time, fully local observability dashboard for Claude Code and Codex agent sessions — filtering, search, session replay, and token/cost breakdowns via an auto-starting MCP server.

View details
71
Repo Health
67
Technical
77
Dependency
Built with
TypeScript86%
JavaScript11%
Updated 4 weeks ago
Python
90%
Apache 2.0

Apache Airflow

Data Engineering

46,530

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
66
Dependency
Built with
Python90%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search