web-data-fetching-swr
SWR Data Fetching Patterns
Quick Guide: SWR implements the stale-while-revalidate caching strategy: show cached data instantly, revalidate in the background. Keys must be stable (strings or stable arrays),
isLoadingis for initial fetches only (useisValidatingfor background refreshes), and all write operations go throughuseSWRMutation. The null key pattern is how you do conditional fetching -- never call hooks conditionally.
<critical_requirements>
CRITICAL: Before Using This Skill
(You MUST use a stable key -- keys should NOT change on every render or you'll trigger infinite requests)
(You MUST handle isLoading vs isValidating correctly -- isLoading is true only on initial fetch with no data)
(You MUST wrap mutations in useSWRMutation for write operations -- NOT useSWR)
(You MUST use named constants for ALL timeout, retry, and interval values -- NO magic numbers)
(You MUST use named exports only -- NO default exports)
More from agents-inc/skills
web-animation-css-animations
CSS Animation patterns - transitions, keyframes, scroll-driven animations, @property, GPU-accelerated properties, accessibility with prefers-reduced-motion
24web-animation-view-transitions
View Transitions API patterns - same-document transitions, cross-document MPA transitions, shared element animations, pseudo-element styling, accessibility
21web-testing-playwright-e2e
Playwright E2E testing patterns - test structure, Page Object Model, locator strategies, assertions, network mocking, visual regression, parallel execution, fixtures, and configuration
21web-styling-cva
Class Variance Authority - type-safe component variant styling with cva(), compound variants, and VariantProps
20web-animation-framer-motion
Motion (formerly Framer Motion) animation patterns - motion components, variants, gestures, layout animations, scroll-linked animations, accessibility
20web-i18n-next-intl
Type-safe i18n for Next.js App Router
19