# TanStack Query

Open\-source server\-state library for fetching, caching and synchronizing asynchronous data with configurable query lifecycles\.

ID: Q933 · Revision: 981

Type: software · License: MIT[^license] · Status: active

Website: https://tanstack.com/query



TanStack Query, formerly React Query, is an open\-source library for managing asynchronous server state in application interfaces\. It tracks fetched data, loading and error states and cache lifecycles around application\-supplied query functions\. It can replace repeated fetching and synchronization code, but it does not supply the backend or make cached data automatically authoritative\.[^overview][^functions]

## Capabilities and substitutions

### Server\-state caching — supported

Tracks asynchronous results by query key and exposes loading/error/data states\.[^overview][^keys]

Use case: Fetching and caching server data in application interfaces · Platforms: Web applications; React adapter documentation inspected · Region: Version, build and integration requirements apply

### Controlled cache freshness — supported

staleTime controls freshness while gcTime concerns inactive retention; static is stricter than Infinity\.[^defaults]

Use case: Fetching and caching server data in application interfaces · Platforms: Web applications; React adapter documentation inspected · Region: Version, build and integration requirements apply

### Automatic HTTP error recognition for any fetcher — limited

Query functions must throw or reject; native fetch status failures require explicit handling\.[^functions]

Use case: Fetching and caching server data in application interfaces · Platforms: Web applications; React adapter documentation inspected · Region: Version, build and integration requirements apply

### Network cancellation — limited

Consume the supplied AbortSignal to cancel supported requests; the guide excludes Suspense query hooks\.[^cancel]

Use case: Fetching and caching server data in application interfaces · Platforms: Web applications; React adapter documentation inspected · Region: Version, build and integration requirements apply

### SSR hydration — supported

Prefetching and hydration are documented, with per\-request cache isolation required\.[^ssr]

Use case: Fetching and caching server data in application interfaces · Platforms: Web applications; React adapter documentation inspected · Region: Version, build and integration requirements apply

### [Substitute for SWR](/swr) — limited

Can replace SWR for React server\-data fetching and caching after adapting keys, query functions and refresh policies\. Cache defaults, mutation integration and cancellation are not interchangeable APIs\.[^overview][^defaults][^functions][^swr]

Use case: Fetching and caching server data in application interfaces · Platforms: Web applications; React adapter documentation inspected · Region: Version, build and integration requirements apply

## References

[^license]: [TanStack Query license](<https://github.com/TanStack/query/blob/main/LICENSE>) — MIT terms (vendor; retrieved 2026-10-07T23:14:37Z)

[^overview]: [TanStack Query overview](<https://tanstack.com/query/latest/docs/framework/react/overview>) — Server state and basic React query workflow (vendor; retrieved 2026-10-07T23:13:58Z)

[^defaults]: [TanStack Query defaults](<https://tanstack.com/query/latest/docs/framework/react/guides/important-defaults>) — Staleness, refetching, static/Infinity and garbage collection (vendor; retrieved 2026-10-07T23:14:06Z)

[^keys]: [TanStack query keys](<https://tanstack.com/query/latest/docs/framework/react/guides/query-keys>) — Changing query dependencies belong in keys (vendor; retrieved 2026-10-07T23:15:02Z)

[^functions]: [TanStack query functions](<https://tanstack.com/query/latest/docs/framework/react/guides/query-functions>) — Rejected promises, undefined and fetch status handling (vendor; retrieved 2026-10-07T23:15:27Z)

[^cancel]: [TanStack query cancellation](<https://tanstack.com/query/latest/docs/framework/react/guides/query-cancellation>) — AbortSignal consumption and Suspense limitations (vendor; retrieved 2026-10-07T23:15:11Z)

[^ssr]: [TanStack server rendering](<https://tanstack.com/query/latest/docs/framework/react/guides/ssr>) — Request\-scoped QueryClient and hydration (vendor; retrieved 2026-10-07T23:14:37Z)

[^swr]: [SWR getting started](<https://swr.vercel.app/docs/getting-started>) — Key/fetcher and React data\-fetching hook (vendor; retrieved 2026-10-07T23:13:58Z)

Source revision: https://substitutefor.net/entities/Q933?revision=981
