Skip to content

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)
Step-by-step guide: how to use TanStack QueryInstall, first run, examples, tips and FAQs

How to get it

  1. 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. 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. 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

ProjectStarsTypeLevelUpdatedBest for
query (this)50.5kLibraryintermediate4 days agoFrontend developers building apps that load data from a server
swr32.5kLibraryintermediate20 days agoReact developers who fetch data from APIs in components
apollo-client19.8kLibraryintermediate5 days agoDevelopers building React apps that query a GraphQL API
ky17.1kLibrarybeginner28 days agoJavaScript or TypeScript developers who already use fetch and want less boilerplate
react-admin27kFrameworkintermediate4 days agoDevelopers building internal admin panels or back-office tools on top of an existing API
fastapi105kLibrarybeginner4 days agoPython 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.