React Query (TanStack Query) (Frontend Standard)
Use TanStack Query for client-side async state and caching when client fetching is required.
When to use React Query
- Data is fetched in the browser (client component) and benefits from caching, retries, refetching.
- You need mutation helpers and invalidation.
When not to use React Query
- If Server Components can fetch the data server-side without client interaction.
- If the data is only needed once at render time and never refetches.
Conventions (required)
- Standardize query keys (project should document its key patterns).
- Prefer invalidation of specific keys over “invalidate everything”.
- Avoid caching sensitive data longer than necessary.