
TanStack Query
A library for fetching, caching, and updating data from servers in web apps.TanStack/query
- Stars
- 50.5k
- Forks
- 4.2k
- Licence
- MIT
- Language
- TypeScript
- Last update
- 4 days ago
- Type
- Library
What it is
TanStack Query is an open-source library for managing server data in web apps. It handles fetching data from an API, caching the results, keeping them in sync, and updating them after changes. The README says it works with REST, GraphQL, or any promise-based fetching, and it has versions for React, Solid, Svelte, and Vue.
- Fetch a list of items from an API and show loading and error states
- Add infinite scroll or paginated lists using the built-in pagination support
- Run a mutation (such as saving a form) and refresh related data afterward
- Prefetch data before a user navigates to a page
Great for
- Frontend developers building apps that load data from a server
- Teams using React, Solid, Svelte, or Vue who want less hand-written loading and caching code
- Apps that need pagination, infinite scroll, or background refresh of data
Not ideal for
- People who only need a simple static site with no server data (the library adds complexity without benefit)
- Non-developers looking for a ready-made app (this is a code library, not an end-user tool)
How to get it
- 1
Install with a package manager
You'll need: Node.js · A JavaScript framework project (React, Solid, Svelte, or Vue)
Clone the repository
git clone https://github.com/TanStack/query - 2
Run it
- Install the package for your framework from npm (see the docs at tanstack.com/query)
- Wrap your app in a query client provider
- Call a query hook with a unique key and an async fetch function
- Use the returned loading, error, and data states in your UI
- 3
Get the most out of it
- Read the official docs at tanstack.com/query for framework-specific setup
- Use the Suspense support if your framework and setup allow it
- Join the Discord or GitHub discussions for community help
Downloads
Strengths
- Covers fetching, caching, refetching, and mutations in one library
- Works with multiple frameworks and any promise-based or GraphQL data source
- Large community: about 50,000 GitHub stars and an MIT license
Trade-offs
- Requires learning its concepts (queries, mutations, cache keys) before it is productive
- The README is truncated here, so detailed setup and API behavior are not covered in this entry
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| query (this) | 50.5k | Library | intermediate | 4 days ago | Frontend developers building apps that load data from a server |
| swr | 32.5k | Library | intermediate | 20 days ago | React developers who fetch data from APIs in components |
| apollo-client | 19.8k | Library | intermediate | 5 days ago | Developers building React apps that query a GraphQL API |
| ky | 17.1k | Library | beginner | 28 days ago | JavaScript or TypeScript developers who already use fetch and want less boilerplate |
| react-admin | 27k | Framework | intermediate | 4 days ago | Developers building internal admin panels or back-office tools on top of an existing API |
| fastapi | 105k | Library | beginner | 4 days ago | Python developers building JSON APIs or back-end services |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.