Libraries
TanStack Query icon

TanStack Query

Handles server-state caching, refetching, and loading/error states so you stop hand-rolling useEffect data fetching.

What is TanStack Query?

TanStack Query (formerly React Query) is a data-fetching and server-state library that handles caching, background refetching, deduplication, and loading/error states for you, instead of every component hand-rolling its own useEffect-plus-useState fetch logic. Server state behaves differently from local UI state, it can go stale, be shared across components, and needs refetching, and Query treats that as its own problem to solve rather than leaving it to general-purpose state management.

Key features

  • Automatic caching and background refetching, so data stays fresh without manual polling logic
  • Request deduplication: multiple components asking for the same data trigger one network call, not several
  • Built-in loading, error, and success states per query, removing a huge amount of boilerplate
  • Optimistic updates and mutation handling for write operations, not just reads
  • Framework adapters for React, Vue, Svelte, Solid, and Angular, so the same mental model travels across stacks

Who it's for

Worth adding to nearly any app that fetches data from an API, since it removes a category of bugs (stale caches, race conditions, redundant requests) that hand-written fetching logic tends to accumulate over time. Less necessary for apps with almost no client-side data fetching, or ones already using a full framework-level data layer (like a meta-framework's built-in loaders) that covers the same ground.

Pricing

Free and open source, with no paid tier.