TanStack Query Server State Manager
tanstack.com
1
Leaving SiteNav
External Link Disclaimer
You are about to visit tanstack.com. This website is not operated by us. We are not responsible for its content or privacy practices.
About this website
TanStack Query is a server-state management library for TypeScript applications that provides a declarative API for fetching, caching, synchronizing, and mutating server data across modern frontend frameworks. With over 5 billion total downloads, 63 million weekly downloads, and nearly 50 thousand GitHub stars, it has become the de facto standard for handling asynchronous data in React and beyond. The library distinguishes server state from client state, recognizing that remote data has unique characteristics including being asynchronous, shared across components, cached for performance, subject to staleness and invalidation, and requiring coordinated background updates. The core abstraction is the query client, a centralized cache that deduplicates concurrent requests, tracks observer subscriptions, and manages the complete lifecycle of each query from initial fetch through garbage collection. Components declare their data needs through hooks like useQuery with a unique query key and an async query function, and the cache coordinates fetching, sharing responses across all subscribed components without redundant network requests. Important defaults handle the tedious work automatically: stale queries refetch on window focus, mount, and reconnect, failed requests retry with exponential backoff, and unused cache entries are garbage collected after a configurable timeout. The mutation API provides a structured lifecycle for write operations with support for optimistic updates that immediately reflect expected changes in the UI, automatic rollback on error, targeted cache invalidation after successful writes, and follow-up refetches to reconcile. DevTools make the entire cache visible during development, showing query keys, observer counts, freshness timers, fetch status, error details, and mutation history. Framework adapters are available for React, Vue, Solid, Svelte, Angular, Preact, and Lit.
Statistics
1
Views
0
Clicks
0
Like
0
Dislike