| name | react-best-practices |
| description | Comprehensive React and Next.js performance optimisation guide with 40+ rules for eliminating waterfalls, optimising bundles, and improving rendering. Use when optimising React or Next.js apps, reviewing performance, refactoring components, hunting wasteful re-renders, reducing bundle size, debugging client/server data-fetching, or tightening rendering paths. Do NOT use for non-React frameworks (Vue, Svelte, Solid, Angular), React Native, or general JavaScript performance unrelated to React. |
React Best Practices - Performance Optimisation
Comprehensive performance optimisation guide for React and Next.js applications with 40+ rules organised by impact level. Designed to help developers eliminate performance bottlenecks and follow best practices.
Quick reference
Critical priorities
- Defer await until needed - Move awaits into branches where they're used
- Use Promise.all() - Parallelize independent async operations
- Avoid barrel imports - Import directly from source files
- Dynamic imports - Lazy-load heavy components
- Strategic Suspense - Stream content while showing layout
Common patterns
Parallel data fetching:
const [user, posts, comments] = await Promise.all([
fetchUser(),
fetchPosts(),
fetchComments()
])
Direct imports:
import { Check } from 'lucide-react'
import Check from 'lucide-react/dist/esm/icons/check'
Dynamic components:
import dynamic from 'next/dynamic'
const MonacoEditor = dynamic(
() => import('./monaco-editor'),
{ ssr: false }
)
Using the guidelines
The guidelines live in the references folder at two depths - pick the one that fits the task:
- references/react-performance-guidelines.md: the complete guide with all rules, code examples, and impact analysis. Read this for a full review or audit.
- references/rules/: one file per rule, named
<category>-<rule>.md (e.g. async-parallel.md, bundle-barrel-imports.md). Read individual files when working on a specific problem - the category pointers below map each rule to its file.
Each rule includes:
- Incorrect/correct code comparisons
- Specific impact metrics
- When to apply the optimisation
- Real-world examples
Categories overview
1. Eliminating Waterfalls (CRITICAL)
Waterfalls are the #1 performance killer. Each sequential await adds full network latency. Rules: references/rules/async-*.md
2. Bundle Size Optimisation (CRITICAL)
Reducing initial bundle size improves Time to Interactive and Largest Contentful Paint. Rules: references/rules/bundle-*.md
3. Server-Side Performance (HIGH)
Optimise server-side rendering and data fetching. Rules: references/rules/server-*.md
4. Client-Side Data Fetching (MEDIUM-HIGH)
Automatic deduplication and efficient data fetching patterns. Rules: references/rules/client-*.md
5. Re-render Optimisation (MEDIUM)
Reduce unnecessary re-renders to minimize wasted computation. Rules: references/rules/rerender-*.md
6. Rendering Performance (MEDIUM)
Optimise the browser rendering process. Rules: references/rules/rendering-*.md
7. JavaScript Performance (LOW-MEDIUM)
Micro-optimisations for hot paths. Rules: references/rules/js-*.md
8. Advanced Patterns (LOW)
Specialized techniques for edge cases. Rules: references/rules/advanced-*.md
Implementation approach
When optimising a React application:
- Profile first: Use React DevTools Profiler and browser performance tools to identify bottlenecks
- Focus on critical paths: Start with eliminating waterfalls and reducing bundle size
- Measure impact: Verify improvements with metrics (LCP, TTI, FID)
- Apply incrementally: Don't over-optimise prematurely
- Test thoroughly: Ensure optimisations don't break functionality
Key metrics to track
- Time to Interactive (TTI): When page becomes fully interactive
- Largest Contentful Paint (LCP): When main content is visible
- First Input Delay (FID): Responsiveness to user interactions
- Cumulative Layout Shift (CLS): Visual stability
- Bundle size: Initial JavaScript payload
- Server response time: TTFB for server-rendered content
Common pitfalls to avoid
❌ Don't:
- Use barrel imports from large libraries
- Block parallel operations with sequential awaits
- Re-render entire trees when only part needs updating
- Load analytics/tracking in the critical path
- Mutate arrays with .sort() instead of .toSorted()
- Create RegExp or heavy objects inside render
✅ Do:
- Import directly from source files
- Use Promise.all() for independent operations
- Memoize expensive components
- Lazy-load non-critical code
- Use immutable array methods
- Hoist static objects outside components
Resources
Version history
v0.1.0 (January 2026)
- Initial release from Vercel Engineering
- 40+ performance rules across 8 categories
- Comprehensive code examples and impact analysis