Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 4 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

TanStack Query

Hooks for managing, caching and synchronizing remote data in React.

State and data fetchingNPM

GitHubWebsite

1. License

License from npm.

github.com/TanStack/query

From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error

What TanStack Query does

TanStack Query treats server data as a cache with a four-step lifecycle (fetch, share, revalidate, collect). Components declare a key and the data they need, and the cache coordinates the fetches.

TanStack Query popularity

88 / 100
Gid Score, #15 overall
92M
downloads a week, npm
50.6K
GitHub stars
458
agent projects use it
TanStack Query: downloads per weeknpm, @tanstack/react-query 91,971,702
TanStack Query: GitHub starsTanStack/query 50,624

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How TanStack Query is used

  • TanStack Query is a dependency in 458 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (9.4% of the 4,867 JavaScript/TypeScript ones), #1 of 53 in state and data fetching.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 2,243; those are left out of every share on this page.
  • The most used alternative in our scan is SWR (51 projects).
  • Projects that use it most often also use Lucide React (77.5%), Tailwind Merge (74.9%), clsx (76.4%).
  • It is more common in projects set up for Roo Code (14.4%) than for Gemini CLI (6.1%).

By coding agent

241 projects, 9.9%
228 projects, 7.0%
197 projects, 6.5%
40 projects, 8.5%
30 projects, 10.8%
29 projects, 6.1%
26 projects, 7.6%
16 projects, 14.4%

Often used with

In 77.5% of its projects
In 74.9% of its projects
In 76.4% of its projects
In 98.5% of its projects
In 70.5% of its projects
In 62.2% of its projects
In 77.3% of its projects
In 88.6% of its projects

TanStack Query in practice

Strengths

Same key, one request

The site says components that ask for the same key share one cache entry. In its words, every observer reads that entry "instead of issuing another request."

Retries and focus refetching come wired, the site says

Under the heading "Deadly defaults," the site lists caching, request deduplication, retries, background refetching, window-focus updates and garbage collection as already set up.

Dependent queries, prefetching and Suspense are on the feature list

The README lists mutations, dependent queries, background updates, prefetching, cancellation and React Suspense support. It also lists pagination and infinite scroll.

A docs router written for agents

TanStack publishes a root <code>llms.txt</code> that points agents to a separate docs index for each product. Query has its own index. The root file says to fetch the linked product docs index first, then follow links from there for deeper context.

Watch out for

Stale values stay on screen during a refresh

The site says "Stale data can remain valuable" and that stale data stays visible while a background request refreshes it.

Unused entries are removed, timing not stated here

The site says data with no observers stays available "briefly" before garbage collection removes it. These pages do not say how long "briefly" is.

Writes are explicit

The site says the parts of a write "stay explicit." Its sample mutation outline shows four parts: an optimistic <code>setQueryData</code>, the awaited server call, a targeted <code>invalidateQueries</code>, and an <code>onError</code> rollback.

More about TanStack Query

Funding
  • GitHub Sponsors: https://github.com/tannerlinsley
  • GitHub Sponsors: https://github.com/TkDodo
  • 158 GitHub sponsors

See all

Head to head
Packages around it
  • class-variance-authority: Variant class names
  • tailwind-merge: Tailwind class merging
  • clsx: Conditional class names
  • react: UI library
  • @radix-ui: UI primitives
  • lucide-react: Icons
More in State and data fetching

Alternatives

TanStack Query This page

MITGid 8892M/wk

SWR

React hooks library for data fetching with caching, revalidation and real-time updates.

MITGid 7728.5M/wk

Compare TanStack Query with another tool

Get started

Install it.

npm install @tanstack/react-query

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## TanStack Query
- Declare data in components with `useQuery()` and an array query key. The site's examples use keys such as `['issues', 'router-cache']` and `['issues', 'project-detail']`.
- Before writing your own request deduplication, retries, background refetching, window-focus updates or garbage collection, check the defaults. The site says these "arrive wired."
- Keep the query function to resolving data. The site says Query owns cancellation, retries and deduplication around it.
- Expect stale data to stay visible while a background request refreshes it. The site says stale data "can remain valuable."
- For optimistic updates, follow the shape of the site's sample mutation outline: `setQueryData(['todos'], next)`, then `await saveTodo(todo)`, then a targeted `invalidateQueries({ queryKey: ['todos'] })`, with a rollback path in `onError`.
- For docs, start from `https://tanstack.com/llms.txt`. It links the Query docs index at `https://tanstack.com/query/latest/llms.txt`. The root file says to fetch the linked product docs index first and follow links from that page only when you need deeper context.