TanStack Query
Web framework / library · Free
Manages asynchronous server data in the interface: caches requests, refreshes data, and handles loading and error states.
Also known as: tanstack/query; tanstack-query; tanstack-query-library

What you can use for free
Code and local use under MIT.
Paid features and costs
Computing resources, self-hosting, and external services are paid for separately if used.
Access and limitations
Code and local use under MIT. Computing resources, self-hosting, and external services are paid for separately if used.
Use cases
- Coordinate server data and interface states
- Connect loading/error UI and cache updates after data changes
Example workflow
A possible workflow; this is not a report of hands-on testing.
Coordinate server data and interface states.
Before you start
- Web application source code and the intended workflow.
- The project's framework and runtime version.
Steps
- Describe the query key and data-fetching function.
- Connect loading/error UI and cache updates after data changes.
- Add real data and error handling; check the production build.
Check your result
- The workflow works after a page refresh and with invalid data.
- The bundle, server rendering, and supported browsers suit the project.
Choosing TanStack Query
Coordinate server data and interface states
Choose this when
- Coordinate server data and interface states
- Connect loading/error UI and cache updates after data changes
Consider alternatives when
- When choosing for this topic, compare TanStack Query with SWR. A candidate to compare under the topic: State and client data, Web interface tools. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together.
- When choosing for this topic, compare TanStack Query with Immer. A candidate to compare under the topic: State and client data. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together.
Requirements
- Define query and mutation functions, cache keys, and loading/error displays in the application.
Things to consider
- Costs and limits of free use: Computing resources, self-hosting, and external services are paid for separately if used.
- Terms of use: MIT for the code; dependencies have separate licenses.
- Caching does not replace server authorization. Define update and error-handling rules for your data source.
Frequently asked questions
What can you use for free in TanStack Query?
Code and local use under MIT.
What additional costs might arise with TanStack Query?
Computing resources, self-hosting, and external services are paid for separately if used.
What terms of use matter for TanStack Query?
MIT for the code; dependencies have separate licenses.
How do you get started with TanStack Query?
Describe the query key and data-fetching function. Connect loading/error UI and cache updates after data changes. Add real data and error handling; check the production build.
What does TanStack Query handle when working with server data?
The library manages fetching, caching, synchronization, and updates of asynchronous state. It supports REST, GraphQL, and other promise-returning sources, refetching, pagination, infinite scrolling, mutations, dependent queries, prefetching, and cancellation. This is a data-state layer, not a ready-made table interface.
Related tasks and approaches
- SWR
A candidate to compare under the topic: State and client data, Web interface tools. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together.
- Immer
A candidate to compare under the topic: State and client data. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together.
- Jotai
A candidate to compare under the topic: State and client data. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together.
License
MIT for the code; dependencies have separate licenses.
MIT — permissive license
You can use, modify, distribute, and sell the code, including in a closed-source commercial product. When sharing copies or substantial portions of the code, retain the license text and copyright notice. You do not need to open-source your entire project; the author provides no warranties.
License termsTechnologies and topics
- TanStack Query
- web
- Development