react-fetch-cache-patterns
FreeRuns bundled scriptsNot checkedReact data-fetching patterns at scale — recommender carousels, infinite feeds, pages with many parallel fetches, dashboards. Covers request orchestration…
by pproenca★ 231 GitHub starsAbout this skill
Experimental React Data Fetching & Caching Best Practices
Implementation patterns for React applications that fetch and cache many API requests without overwhelming the backend. 48 rules across 8 categories, ordered by execution lifecycle impact — earlier categories cascade through everything downstream. Templates show both library-based (TanStack Query, SWR) and library-free (pure React + AbortController) implementations so the patterns are usable regardless of stack constraints.
When to Apply
- Writing or reviewing a React component that calls
fetch,useQuery,useSWR, or any data-fetching hook - Designing a list, feed, or carousel that displays many items each requiring data
- Investigating "the backend is getting hammered" or "the page loads slowly" symptoms
- Choosing between client-side fetching, route loaders, server components, or SSR
- Implementing prefetch, retry, optimistic updates, or any failure-handling logic
- Refactoring code that already does data fetching but with waterfalls, no cache strategy, or no concurrency limits
Rule Categories by Priority
| # | Category | Impact | Prefix | Rules |
|---|---|---|---|---|
| 1 | Request Orchestration | CRITICAL | orch- |
7 |
| 2 | Cache Strategy | CRITICAL | cache- |
7 |
| 3 | Backend Protection | CRITICAL | protect- |
7 |
| 4 | Prefetch & Hydration | HIGH | prefetch- |
6 |
| 5 | Failure Resilience | HIGH | resilience- |
6 |
| 6 | Feed & Carousel Patterns | MEDIUM-HIGH | feed- |
7 |
| 7 | Mutation & Invalidation | MEDIUM | mutate- |
4 |
| 8 | Component Patterns | MEDIUM | render- |
4 |
Quick Reference
1. Request Orchestration (CRITICAL)
orch-parallelize-independent-fetches— UsePromise.allfor independent requests; never serialawaitorch-batch-n-plus-one-fanout— Collapse per-row fetches via DataLoader-style batchingorch-dedupe-in-flight-requests— One in-flight request per key, shared across subscribersorch-lift-fetch-to-route-loader— Fetch in parallel with route chunk downloadorch-avoid-effect-chains— Flatten the dependency graph; only true dependencies waitorch-server-fetch-when-possible— Move fetches to RSC/server when they don't depend on client stateorch-prefer-bulk-endpoint-for-fanout— One bulk request beats N parallel requests
2. Cache Strategy (CRITICAL)
cache-deterministic-keys— Canonicalize cache keys; strip undefined, sort arrayscache-normalize-shared-entities— Store each entity once; views hold referencescache-set-stale-time— TunestaleTimeto data volatility, not refresh frequencycache-stale-while-revalidate— Render stale instantly; revalidate in backgroundcache-select-subscribed-fields— Subscribe to slices, not whole objectscache-shared-key-factory— One typed source of truth for keys; prevents read/write driftcache-tiered-stale-fresh— DifferentstaleTimeper data class (realtime, fresh, warm, cold, static)
3. Backend Protection (CRITICAL)
protect-concurrency-limit-fanout— Cap simultaneous requests withp-limit/semaphoreprotect-collapse-identical-requests— In-flight dedup at the fetch layerprotect-debounce-user-driven-fetches— Wait for user pause before firing search/filter requestsprotect-throttle-scroll-triggered— Use IntersectionObserver for viewport-triggered fetchesprotect-jittered-retry-backoff— Add random jitter to prevent thundering-herd retriesprotect-circuit-breaker— Stop calling persistently failing endpoints for a cooldown windowprotect-rate-limit-aware-client— HonorRetry-AfterandX-RateLimit-*headers
4. Prefetch & Hydration (HIGH)
prefetch-hover-intent-links— Prefetch on hover/pointerdown for instant navigationprefetch-parallel-loader-queries— Parallelize independent queries inside loaders- [`prefetch-hydrate-server-cach
Install react-fetch-cache-patterns in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
FAQ
What does the react-fetch-cache-patterns skill do?
React data-fetching patterns at scale — recommender carousels, infinite feeds, pages with many parallel fetches, dashboards. Covers request orchestration (parallelism, batching, deduplication), cache strategy (keys, normalization, staleTime, SWR), backend protection (concurrency caps, debounce/throttle, jittered retries, circuit breakers), prefetching (route loaders, hover/intent, idle, server hydration), failure resilience (AbortController, timeouts, error boundaries, stale fallback, idempotent mutations), and feed/carousel patterns (virtualization, cursor pagination, summary/detail split). Includes 5 ready-to-use scaffolding templates (resource query hook, carousel data loader, infinite feed, hover-prefetch link, request collapser). Trigger when building, reviewing, or refactoring React components that fetch data — even if the user doesn't explicitly mention "performance" or "scale".
How do I install the react-fetch-cache-patterns skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the react-fetch-cache-patterns skill run scripts?
Yes, this skill bundles executable scripts. Review the source before installing.
Related skills
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
by Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
by Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
by Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
by Anthropic