Open navigation menu

TanStack Query

Powerful asynchronous state management for data fetching, caching, and synchronization in React, Vue, Solid and Svelte.

Version: v5.32

Official Documentation ↗

Installation

npmnpm install @tanstack/react-query
pnpmpnpm add @tanstack/react-query
yarnyarn add @tanstack/react-query

Methods

FAQ

Is TanStack Query a replacement for Redux or Zustand?
No. TanStack Query manages server state (data fetched from APIs), while Redux/Zustand manage client state (UI state, form state). They complement each other and are often used together.
How does automatic caching work?
Each query is cached by its queryKey. When the same key is requested again, cached data is shown immediately while a background refetch occurs if the data is stale. Stale time and cache time are configurable per query.
Does it work outside of React?
Yes. TanStack Query has framework-specific packages for React, Vue, Solid, and Svelte. The core @tanstack/query-core package is framework-agnostic.