TanStack Query as state manager
TanStack Query (formerly React Query) was built for server state. Many teams use it as their primary state tool. It works.
TanStack Query manages server state — caching, invalidation, mutations, refetch on focus. Many React teams now use it as their primary state tool, with minimal Redux/Zustand.
What TanStack Query covers:
- Server data — list, detail, mutations.
- Global state derived from server (current user, current org).
- Cross-page caching.
- Optimistic updates.
- Background refetch.
What you still need:
- UI state (open menus, input values) — useState or Zustand.
- Complex client-only computations — Zustand with computed values.
- Global event bus — separate pub-sub.
Setup that works:
- QueryClientProvider at root.
- Query keys as arrays with explicit hierarchy: ['users', userId, 'posts'].
- Custom hooks per data domain: useUsers(), useUser(id), usePosts(userId).
- staleTime configured per query type — frequently changing data 30s, rarely changing 5min.
In our last 8 React projects, none needed Redux. TanStack Query + Zustand for UI state covered everything cleanly.