| name | react-best-practices |
| description | React and Next.js performance optimization from Vercel Engineering. Use when building React components, optimizing performance, eliminating waterfalls, reducing bundle size, reviewing code for performance issues, or implementing server/client-side optimizations. |
| allowed-tools | Read, Write, Edit, Glob, Grep, Bash |
Next.js & React Performance Expert
From Vercel Engineering - 57 optimization rules prioritized by impact
Philosophy: Eliminate waterfalls first, optimize bundles second, then micro-optimize.
šÆ Selective Reading Rule (MANDATORY)
Read ONLY sections relevant to your task! Check the content map below and load what you need.
š“ For performance reviews: Start with CRITICAL sections (1-2), then move to HIGH/MEDIUM.
š Content Map
| File | Impact | Rules | When to Read |
|---|
1-async-eliminating-waterfalls.md | š“ CRITICAL | 5 rules | Slow page loads, sequential API calls, data fetching waterfalls |
2-bundle-bundle-size-optimization.md | š“ CRITICAL | 5 rules | Large bundle size, slow Time to Interactive, First Load issues |
3-server-server-side-performance.md | š HIGH | 7 rules | Slow SSR, API route optimization, server-side waterfalls |
4-client-client-side-data-fetching.md | š” MEDIUM-HIGH | 4 rules | Client data management, SWR patterns, deduplication |
5-rerender-re-render-optimization.md | š” MEDIUM | 12 rules | Excessive re-renders, React performance, memoization |
6-rendering-rendering-performance.md | š” MEDIUM | 9 rules | Rendering bottlenecks, virtualization, image optimization |
7-js-javascript-performance.md | āŖ LOW-MEDIUM | 12 rules | Micro-optimizations, caching, loop performance |
8-advanced-advanced-patterns.md | šµ VARIABLE | 3 rules | Advanced React patterns, useLatest, init-once |
9-cache-components.md | š“ CRITICAL | 4 sections | Next.js 16+ Only: use cache, cacheLife, PPR, cacheTag |
Total: 57 rules across 8 categories
š Quick Decision Tree
What's your performance issue?
š Slow page loads / Long Time to Interactive
ā Read Section 1: Eliminating Waterfalls
ā Read Section 2: Bundle Size Optimization
š¦ Large bundle size (> 200KB)
ā Read Section 2: Bundle Size Optimization
ā Check: Dynamic imports, barrel imports, tree-shaking
š„ļø Slow Server-Side Rendering
ā Read Section 3: Server-Side Performance
ā Check: Parallel data fetching, streaming
š Too many re-renders / UI lag
ā Read Section 5: Re-render Optimization
ā Check: React.memo, useMemo, useCallback
šØ Rendering performance issues
ā Read Section 6: Rendering Performance
ā Check: Virtualization, layout thrashing
š Client-side data fetching problems
ā Read Section 4: Client-Side Data Fetching
ā Check: SWR deduplication, localStorage
⨠Need advanced patterns
ā Read Section 8: Advanced Patterns
š **Next.js 16+ Performance (Caching & PPR)**
ā Read Section 9: Cache Components
š Impact Priority Guide
Use this order when doing comprehensive optimization:
1ļøā£ CRITICAL (Biggest Gains - Do First):
āā Section 1: Eliminating Waterfalls
ā āā Each waterfall adds full network latency (100-500ms+)
āā Section 2: Bundle Size Optimization
āā Affects Time to Interactive and Largest Contentful Paint
2ļøā£ HIGH (Significant Impact - Do Second):
āā Section 3: Server-Side Performance
āā Eliminates server-side waterfalls, faster response times
3ļøā£ MEDIUM (Moderate Gains - Do Third):
āā Section 4: Client-Side Data Fetching
āā Section 5: Re-render Optimization
āā Section 6: Rendering Performance
4ļøā£ LOW (Polish - Do Last):
āā Section 7: JavaScript Performance
āā Section 8: Advanced Patterns
š„ **MODERN (Next.js 16+):**
āā Section 9: Cache Components (Replaces most traditional revalidation)
š Related Skills
| Need | Skill |
|---|
| API design patterns | @[skills/api-patterns] |
| Database optimization | @[skills/database-design] |
| Testing strategies | @[skills/testing-patterns] |
| UI/UX design principles | @[skills/frontend-design] |
| TypeScript patterns | @[skills/typescript-expert] |
| Deployment & DevOps | @[skills/deployment-procedures] |
ā
Performance Review Checklist
Before shipping to production:
Critical (Must Fix):
High Priority:
Medium Priority:
Low Priority (Polish):
ā Anti-Patterns (Common Mistakes)
DON'T:
- ā Use sequential
await for independent operations
- ā Import entire libraries when you need one function
- ā Use barrel exports (
index.ts re-exports) in app code
- ā Skip dynamic imports for large components/libraries
- ā Fetch data in useEffect without deduplication
- ā Forget to memoize expensive computations
- ā Use client components when server components work
DO:
- ā
Fetch data in parallel with
Promise.all()
- ā
Use dynamic imports:
const Comp = dynamic(() => import('./Heavy'))
- ā
Import directly:
import { specific } from 'library/specific'
- ā
Use Suspense boundaries for better UX
- ā
Leverage React Server Components
- ā
Measure performance before optimizing
- ā
Use Next.js built-in optimizations (next/image, next/font)
šÆ How to Use This Skill
For New Features:
- Check Section 1 & 2 while building (prevent waterfalls, keep bundle small)
- Use server components by default (Section 3)
- Apply memoization for expensive operations (Section 5)
For Performance Reviews:
- Start with Section 1 (waterfalls = biggest impact)
- Then Section 2 (bundle size)
- Then Section 3 (server-side)
- Finally other sections as needed
For Debugging Slow Performance:
- Identify the symptom (slow load, lag, etc.)
- Use Quick Decision Tree above
- Read relevant section
- Apply fixes in priority order
š Learning Path
Beginner (Focus on Critical):
ā Section 1: Eliminating Waterfalls
ā Section 2: Bundle Size Optimization
Intermediate (Add High Priority):
ā Section 3: Server-Side Performance
ā Section 5: Re-render Optimization
Advanced (Full Optimization):
ā All sections + Section 8: Advanced Patterns
š Validation Script
| Script | Purpose | Command |
|---|
scripts/react_performance_checker.py | Automated performance audit | python scripts/react_performance_checker.py <project_path> |
š Section Details
Section 1: Eliminating Waterfalls (CRITICAL)
Impact: Each waterfall adds 100-500ms+ latency
Key Concepts: Parallel fetching, Promise.all(), Suspense boundaries, preloading
Section 2: Bundle Size Optimization (CRITICAL)
Impact: Directly affects Time to Interactive, Largest Contentful Paint
Key Concepts: Dynamic imports, tree-shaking, barrel import avoidance
Section 3: Server-Side Performance (HIGH)
Impact: Faster server responses, better SEO
Key Concepts: Parallel server fetching, streaming, API route optimization
Section 4: Client-Side Data Fetching (MEDIUM-HIGH)
Impact: Reduces redundant requests, better UX
Key Concepts: SWR deduplication, localStorage caching, event listeners
Section 5: Re-render Optimization (MEDIUM)
Impact: Smoother UI, less wasted computation
Key Concepts: React.memo, useMemo, useCallback, component structure
Section 6: Rendering Performance (MEDIUM)
Impact: Better rendering efficiency
Key Concepts: Virtualization, image optimization, layout thrashing
Section 7: JavaScript Performance (LOW-MEDIUM)
Impact: Incremental improvements in hot paths
Key Concepts: Loop optimization, caching, RegExp hoisting
Section 8: Advanced Patterns (VARIABLE)
Impact: Specific use cases
Key Concepts: useLatest hook, init-once patterns, event handler refs
š Best Practices Summary
Golden Rules:
- Measure first - Use React DevTools Profiler, Chrome DevTools
- Biggest impact first - Waterfalls ā Bundle ā Server ā Micro
- Don't over-optimize - Focus on real bottlenecks
- Use platform features - Next.js has optimizations built-in
- Think about users - Real-world conditions matter
Performance Mindset:
- Every
await in sequence = potential waterfall
- Every
import = potential bundle bloat
- Every re-render = wasted computation (if unnecessary)
- Server components = less JavaScript to ship
- Measure, don't guess
Source: Vercel Engineering
Date: January 2026
Version: 1.0.0
Total Rules: 57 across 8 categories