web-data-fetching-swr
Installation
SKILL.md
SWR Patterns
Quick Guide: SWR renders the cached value immediately and revalidates behind it, so the cache key is the whole identity of a request and an unstable key is the single most expensive mistake here.
isLoadingcovers the first fetch only andisValidatingcovers every fetch, which is why using the second as a spinner hides the data SWR exists to show. Reads areuseSWR, writes areuseSWRMutation, and anullkey is how a request is skipped without breaking the rules of hooks.
Detailed Resources:
- examples/core.md — fetchers, key shapes, state handling,
SWRConfig - examples/mutations.md —
useSWRMutation, optimistic updates,populateCache, globalmutate - examples/caching.md — revalidation strategies, prefetching, cache persistence
- examples/pagination.md —
useSWRInfinite, infinite scroll, offset and filtered paging - examples/conditional.md — the null key, dependent queries, function keys
- examples/error-handling.md — retry policy, status-specific handling, offline
- examples/suspense.md — suspense mode and server-rendered fallback data
- reference.md — every config option with its default, and the hook return shapes