affaan-m/ecc/react-performance
Claude Code and agent skill by affaan-m/ecc
- community
Checking that the SKILL.md file is still in the repository.
React and Next.js performance optimization patterns adapted from Vercel Engineering's React Best Practices (https://github.com/vercel-labs/agent-skills). Organizes 70+ rules across 8 priority categories — waterfalls, bundle size, server-side, client fetching, re-render, rendering, JS micro-perf, advanced. Use when writing, reviewing, or refactoring React/Next.js code for performance.
Install
npx vskill@latest install affaan-m/ecc/react-performanceSKILL.md
The same SKILL.md was published earlier as affaan-m/ecc/react-performance.
React Performance
Performance optimization patterns for React 18/19 and Next.js, adapted from Vercel Labs `react-best-practices` (MIT, v1.0.0). This skill organizes rules by priority and provides decision-tree guidance for active code review and refactoring.
When to Activate
- Writing or reviewing React/Next.js code for performance
- Diagnosing slow page loads, slow interactions, or high CPU on the client
- Auditing bundle size or Lighthouse Core Web Vitals regressions
- Removing waterfalls in Server Components / API routes
- Reducing client-side re-renders
- Optimizing long lists, animations, or hydration
- Auditing optimization choices in PRs touching
app/,pages/,components/, or data layers
Priority Index
| Priority | Category | Prefix | When it matters | |
|---|---|---|---|---|
| 1 — CRITICAL | Eliminating Waterfalls | async- | Anytime await is followed by independent await | |
| 2 — CRITICAL | Bundle Size Optimization | bundle- | First-load JS, route-level imports, third-party libs | |
| 3 — HIGH | Server-Side Performance | server- | RSC, Server Actions, API routes, SSR | |
| 4 — MEDIUM-HIGH | Client-Side Data Fetching | client- | SWR / TanStack Query / raw fetch in hooks | |
| 5 — MEDIUM | Re-render Optimization | rerender- | High-frequency state updates, parent-child fan-out | |
| 6 — MEDIUM | Rendering Performance | rendering- | Long lists, animations, hydration | |
| 7 — LOW-MEDIUM | JavaScript Performance | js- | Hot loops, frequent allocations | |
| 8 — LOW | Advanced Patterns | advanced- | Effect-event integration, stable refs |
1. Eliminating Waterfalls (CRITICAL)
"Waterfalls are the #1 performance killer" — every sequentialawaitadds full network latency.
Cheap conditions before await
Check sync conditions (props, env, hardcoded flags) before awaiting remote data.
Defer awaits until used
Move await into the branch that uses it.
Promise.all for independent work
Partial dependencies — start early, await late
Suspense for streaming
Push <Suspense> boundaries close to the data so the page paints what it can while slower sub-trees stream in. The trade-off: layout shift when content arrives — reserve space (skeleton or min-height).
Server Components: parallel through composition
2. Bundle Size Optimization (CRITICAL)
Direct imports, not barrels
Barrel index.ts files force the bundler to walk the entire module graph even when tree-shaking removes most of it. Direct imports save 200-800ms of first-load JS in many real-world apps.
Next.js 13.5+ has Optimize Package Imports that automates this for listed packages — use it; manual direct imports still required for non-listed libs.
Statically analyzable paths
Dynamic imports for heavy components
Defer third-party scripts
Load analytics, logging, support widgets AFTER hydration. Use next/script with strategy="afterInteractive" (default) or "lazyOnload".
Conditional module loading
Preload on hover/focus
Trigger <link rel="preload"> or import() on hover so the bundle is in cache by the time the user clicks.
3. Server-Side Performance (HIGH)
Authenticate Server Actions like API routes
Every "use server" function is a public endpoint. Authenticate AND authorize inside the action — never rely on the calling Client Component's gating.
React.cache() for per-request deduplication
React.cache dedupes within a single request. Calling getUser("1") from three Server Components in the same render = one DB query.
LRU cache for cross-request data
For data that does NOT change per request (config, lookup tables), cache outside React with an LRU cache or unstable_cache.
Avoid duplicate serialization in RSC props
When a Server Component renders the same data into multiple Client Components, the data is serialized once per consumer. Lift the Client Component up and pass children.
Hoist static I/O to module scope
No mutable module-level state in RSC/SSR
Module state on the server is shared across all requests — a race condition between users. Use request-scoped storage (headers(), cookies(), async context) instead.
Minimize data passed to Client Components
Only serialize what the Client needs. Strip fields, paginate, project columns at the DB layer.
Parallelize nested fetches with Promise.all per item
Use after() for non-blocking work
Next.js 15 after() runs work after the response is sent — logging, cache warming, analytics.
4. Client-Side Data Fetching (MEDIUM-HIGH)
SWR / TanStack Query for deduplication
Multiple components calling useUser(id) should share one network request and one cache entry. Use SWR or TanStack Query — never roll your own useEffect + fetch for shared data.
Deduplicate global event listeners
Passive listeners for scroll
Improves scrolling smoothness; the listener cannot preventDefault().
localStorage: version + minimize
- Always store a
versionfield; bump on schema change and migrate or discard old data - Keep payloads small —
localStorageis synchronous and blocks main thread
5. Re-render Optimization (MEDIUM)
Don't subscribe to state used only in callbacks
Extract expensive work into memoized components
Hoist default non-primitive props
Primitive dependencies in effects
Subscribe to derived booleans, not raw values
Derive during render, never via useEffect
Functional setState for stable callbacks
Lazy state initializer for expensive values
Avoid memo for simple primitives
useMemo(() => x + 1, [x]) is overhead. Memo earns its keep on object identity and expensive computation.
Split hooks with independent deps
Move interaction logic into event handlers
Event handlers run only on the user action — useEffect re-runs whenever deps change.
startTransition for non-urgent updates
useDeferredValue for expensive renders
useRef for transient frequent values
For values that change often but should not trigger re-render (timestamps, last-key, accumulators).
Don't define components inside components
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/react-performance/SKILL.md
Popularity
- Repository stars
- 214,428
- Repository forks
- 32,950
- 7-day trend score
- 61
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/affaan-m/ecc/react-performance)