The de-facto standard for server state in React — caching, retries, and invalidation done right.
TanStack Query (formerly React Query) is a data-fetching and server-state management library that has become the default answer to "how do I fetch data in React." It wraps `fetch` (or Axios, or whatever you like) with a cache, automatic background refetching, request deduplication, retry logic, and a tiny set of hooks that replace the boilerplate of `useEffect` + `useState` for almost every server-state use case. The killer feature is cache invalidation. Instead of wiring up loading flags, error boundaries, and `setState` calls everywhere, you write `useQuery({ queryKey: ['todos'], queryFn })` and the library handles dedupe, retry, refetch-on-focus, refetch-on-mount, and stale-while-revalidate for you. Mutations invalidate the right queries automatically. It is framework-agnostic — the same API works in React, Vue, Solid, Svelte, and Angular.
Stale-while-revalidate, automatic deduplication, and configurable staleness windows.
Refetches on window focus, mount, and interval, all configurable per query.
Mutate → auto-invalidate the queries that depend on the data you changed.
Same API for React, Vue, Solid, Svelte, and Angular.
An optional Devtools panel shows the live cache, query keys, and observer state.
Login to comment
The Devtools panel alone is worth it. Watching cache invalidation happen in real time is such a quality-of-life improvement.