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 |
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
📊 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
🔗 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
🧠 Knowledge Modules (Fractal Skills)
1---
2name: nextjs-react-expert
3description: React and Next.js performance optimization from Vercel Engineering.
4category: development
5version: 4.1.0-fractal
6layer: master-skill
7metadata:
8 source: https://skillmd.com/skills/dokhacgiakhoa/nextjs-react-expert
9---
10
11# Next.js & React Performance Expert
12
13> **From Vercel Engineering** - 57 optimization rules prioritized by impact
14> **Philosophy:** Eliminate waterfalls first, optimize bundles second, then micro-optimize.
15
16---
17
18## 🎯 Selective Reading Rule (MANDATORY)
19
20**Read ONLY sections relevant to your task!** Check the content map below and load what you need.
21
22> 🔴 **For performance reviews: Start with CRITICAL sections (1-2), then move to HIGH/MEDIUM.**
23
24---
25
26## 📑 Content Map
27
28| File | Impact | Rules | When to Read |
29|------|--------|-------|--------------|
30| `1-async-eliminating-waterfalls.md` | 🔴 **CRITICAL** | 5 rules | Slow page loads, sequential API calls, data fetching waterfalls |
31| `2-bundle-bundle-size-optimization.md` | 🔴 **CRITICAL** | 5 rules | Large bundle size, slow Time to Interactive, First Load issues |
32| `3-server-server-side-performance.md` | 🟠 **HIGH** | 7 rules | Slow SSR, API route optimization, server-side waterfalls |
33| `4-client-client-side-data-fetching.md` | 🟡 **MEDIUM-HIGH** | 4 rules | Client data management, SWR patterns, deduplication |
34| `5-rerender-re-render-optimization.md` | 🟡 **MEDIUM** | 12 rules | Excessive re-renders, React performance, memoization |
35| `6-rendering-rendering-performance.md` | 🟡 **MEDIUM** | 9 rules | Rendering bottlenecks, virtualization, image optimization |
36| `7-js-javascript-performance.md` | ⚪ **LOW-MEDIUM** | 12 rules | Micro-optimizations, caching, loop performance |
37| `8-advanced-advanced-patterns.md` | 🔵 **VARIABLE** | 3 rules | Advanced React patterns, useLatest, init-once |
38
39**Total: 57 rules across 8 categories**
40
41---
42
43## 🚀 Quick Decision Tree
44
45**What's your performance issue?**
46
47```
48🐌 Slow page loads / Long Time to Interactive
49 → Read Section 1: Eliminating Waterfalls
50 → Read Section 2: Bundle Size Optimization
51
52📦 Large bundle size (> 200KB)
53 → Read Section 2: Bundle Size Optimization
54 → Check: Dynamic imports, barrel imports, tree-shaking
55
56🖥️ Slow Server-Side Rendering
57 → Read Section 3: Server-Side Performance
58 → Check: Parallel data fetching, streaming
59
60🔄 Too many re-renders / UI lag
61 → Read Section 5: Re-render Optimization
62 → Check: React.memo, useMemo, useCallback
63
64🎨 Rendering performance issues
65 → Read Section 6: Rendering Performance
66 → Check: Virtualization, layout thrashing
67
68🌐 Client-side data fetching problems
69 → Read Section 4: Client-Side Data Fetching
70 → Check: SWR deduplication, localStorage
71
72✨ Need advanced patterns
73 → Read Section 8: Advanced Patterns
74```
75
76---
77
78## 📊 Impact Priority Guide
79
80**Use this order when doing comprehensive optimization:**
81
82```
831️⃣ CRITICAL (Biggest Gains - Do First):
84 ├─ Section 1: Eliminating Waterfalls
85 │ └─ Each waterfall adds full network latency (100-500ms+)
86 └─ Section 2: Bundle Size Optimization
87 └─ Affects Time to Interactive and Largest Contentful Paint
88
892️⃣ HIGH (Significant Impact - Do Second):
90 └─ Section 3: Server-Side Performance
91 └─ Eliminates server-side waterfalls, faster response times
92
933️⃣ MEDIUM (Moderate Gains - Do Third):
94 ├─ Section 4: Client-Side Data Fetching
95 ├─ Section 5: Re-render Optimization
96 └─ Section 6: Rendering Performance
97
984️⃣ LOW (Polish - Do Last):
99 ├─ Section 7: JavaScript Performance
100 └─ Section 8: Advanced Patterns
101```
102
103---
104
105## 🔗 Related Skills
106
107| Need | Skill |
108|------|-------|
109| API design patterns | `@[skills/api-patterns]` |
110| Database optimization | `@[skills/database-design]` |
111| Testing strategies | `@[skills/testing-patterns]` |
112| UI/UX design principles | `@[skills/frontend-design]` |
113| TypeScript patterns | `@[skills/typescript-expert]` |
114| Deployment & DevOps | `@[skills/deployment-procedures]` |
115
116---
117
118## ✅ Performance Review Checklist
119
120Before shipping to production:
121
122**Critical (Must Fix):**
123- [ ] No sequential data fetching (waterfalls eliminated)
124- [ ] Bundle size < 200KB for main bundle
125- [ ] No barrel imports in app code
126- [ ] Dynamic imports used for large components
127- [ ] Parallel data fetching where possible
128
129**High Priority:**
130- [ ] Server components used where appropriate
131- [ ] API routes optimized (no N+1 queries)
132- [ ] Suspense boundaries for data fetching
133- [ ] Static generation used where possible
134
135**Medium Priority:**
136- [ ] Expensive computations memoized
137- [ ] List rendering virtualized (if > 100 items)
138- [ ] Images optimized with next/image
139- [ ] No unnecessary re-renders
140
141**Low Priority (Polish):**
142- [ ] Hot path loops optimized
143- [ ] RegExp patterns hoisted
144- [ ] Property access cached in loops
145
146---
147
148## ❌ Anti-Patterns (Common Mistakes)
149
150**DON'T:**
151- ❌ Use sequential `await` for independent operations
152- ❌ Import entire libraries when you need one function
153- ❌ Use barrel exports (`index.ts` re-exports) in app code
154- ❌ Skip dynamic imports for large components/libraries
155- ❌ Fetch data in useEffect without deduplication
156- ❌ Forget to memoize expensive computations
157- ❌ Use client components when server components work
158
159**DO:**
160- ✅ Fetch data in parallel with `Promise.all()`
161- ✅ Use dynamic imports: `const Comp = dynamic(() => import('./Heavy'))`
162- ✅ Import directly: `import { specific } from 'library/specific'`
163- ✅ Use Suspense boundaries for better UX
164- ✅ Leverage React Server Components
165- ✅ Measure performance before optimizing
166- ✅ Use Next.js built-in optimizations (next/image, next/font)
167
168---
169
170## 🎯 How to Use This Skill
171
172## 🧠 Knowledge Modules (Fractal Skills)
173
174### 1. [For New Features:](./sub-skills/for-new-features.md)
175### 2. [For Performance Reviews:](./sub-skills/for-performance-reviews.md)
176### 3. [For Debugging Slow Performance:](./sub-skills/for-debugging-slow-performance.md)
177### 4. [Section 1: Eliminating Waterfalls (CRITICAL)](./sub-skills/section-1-eliminating-waterfalls-critical.md)
178### 5. [Section 2: Bundle Size Optimization (CRITICAL)](./sub-skills/section-2-bundle-size-optimization-critical.md)
179### 6. [Section 3: Server-Side Performance (HIGH)](./sub-skills/section-3-server-side-performance-high.md)
180### 7. [Section 4: Client-Side Data Fetching (MEDIUM-HIGH)](./sub-skills/section-4-client-side-data-fetching-medium-high.md)
181### 8. [Section 5: Re-render Optimization (MEDIUM)](./sub-skills/section-5-re-render-optimization-medium.md)
182### 9. [Section 6: Rendering Performance (MEDIUM)](./sub-skills/section-6-rendering-performance-medium.md)
183### 10. [Section 7: JavaScript Performance (LOW-MEDIUM)](./sub-skills/section-7-javascript-performance-low-medium.md)
184### 11. [Section 8: Advanced Patterns (VARIABLE)](./sub-skills/section-8-advanced-patterns-variable.md)