talira

TanStack Query

Async server-state management and data fetching for TS/JS, React, Vue, Svelte, Solid and Angular

open sourceMITself-hostablefree

TanStack Query (formerly React Query) is an open source library for fetching, caching and updating server state in web apps. Components declare the data they need with query keys, and Query's cache coordinates fetches, shared subscribers, freshness, retries and background updates, with request deduplication, refetching when the window regains focus and garbage collection of unused data built in. Stale data renders immediately from the cache while a background request refreshes it. Mutations handle optimistic updates, pending state, rollback on error and targeted cache invalidation. Devtools, cache persistence to storage, offline mutation queues, an ESLint plugin and codemods round it out. It has adapters for React, Preact, Vue, Svelte, Solid, Angular and Lit on a framework-agnostic core, is written in TypeScript, and is MIT licensed by TanStack.

Problems it solves

  • cache API responses in my React app and refetch them automatically
  • stop writing useEffect and loading-state boilerplate to fetch data
  • keep server data fresh in the background without blocking the UI
  • deduplicate identical API requests from many components
  • optimistic updates with rollback when a mutation fails
  • manage server state separately from client state in a frontend app
  • data fetching and caching for Vue, Svelte, Solid or Angular
  • persist query cache to local storage for offline use
  • inspect and debug my app's cached server data with devtools

Features

  • query cache with query keys
  • request deduplication
  • automatic retries
  • background refetching and window-focus updates
  • stale-while-revalidate rendering
  • garbage collection of unused queries
  • mutations with optimistic updates, rollback and invalidation
  • devtools
  • cache persistence with sync and async storage persisters
  • offline mutation queues
View 3 more
  • ESLint plugin and codemods
  • adapters for React, Preact, Vue, Svelte, Solid, Angular and Lit
  • framework-agnostic core

Capabilities

Has official SDKsplan not known

Alternatives

The same job

These do what TanStack Query does.

  1. Redux A JS library for predictable global state management

Compare TanStack Query with the top 3