tanstack-query
Installation
SKILL.md
TanStack Query
Mental Model
TanStack Query is an async state manager, NOT a data fetching library. It doesn't fetch data - you provide a queryFn that returns a Promise. React Query handles caching, deduplication, background updates, and stale data management.
Key distinctions:
| Concept | Client State | Server State (React Query) |
|---|---|---|
| Ownership | You control completely | Persisted remotely |
| Availability | Synchronous | Asynchronous |
| Updates | Predictable | Can become outdated |
| Management | useState/Zustand | TanStack Query |
Query keys = dependency array: Parameters used in your queryFn must appear in the queryKey. This ensures automatic refetches when dependencies change and prevents stale closure bugs.