Data Fetching
This skill describes patterns for client-side data fetching and caching.
1. Core rules
- •Prefer a single data access layer (API client + feature APIs).
- •Use stable query keys for caching.
- •Invalidate caches intentionally on mutations.
- •Keep loading/error UX consistent (Suspense or explicit states).
2. Query key pattern
Example shape:
- •
["users", "list", filters] - •
["users", "detail", userId]
Avoid:
- •keys that depend on unstable object identity
- •mixing unrelated resources in a single key
3. Mutation pattern
After a successful mutation:
- •invalidate affected list queries
- •update detail caches when possible
4. Error handling
- •Show user-friendly errors.
- •Capture exceptions to monitoring with route/feature context (when available).