name: react-best-practices
description: Vercel's React and Next.js performance optimization guide with 57 rules across 8 categories. Use when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance, bundle size, and rendering efficiency.
tags: [react, performance, nextjs]
Vercel React Best Practices
Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains 57 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.
When to Apply
Reference these guidelines when:
Writing new React components or Next.js pages
Implementing data fetching (client or server-side)
Reviewing code for performance issues
Refactoring existing React/Next.js code
Optimizing bundle size or load times
Rule Categories by Priority
Priority
Category
Impact
Prefix
1
Eliminating Waterfalls
CRITICAL
async-
2
Bundle Size Optimization
CRITICAL
bundle-
3
Server-Side Performance
HIGH
server-
4
Client-Side Data Fetching
MEDIUM-HIGH
client-
5
Re-render Optimization
MEDIUM
rerender-
6
Rendering Performance
MEDIUM
rendering-
7
JavaScript Performance
LOW-MEDIUM
js-
8
Advanced Patterns
LOW
advanced-
Quick Reference
1. Eliminating Waterfalls (CRITICAL)
async-defer-await - Move await into branches where actually used
async-parallel - Use Promise.all() for independent operations
async-dependencies - Use better-all for partial dependencies
async-api-routes - Start promises early, await late in API routes
async-suspense-boundaries - Use Suspense to stream content
js-min-max-loop - Use loop for min/max instead of sort
js-set-map-lookups - Use Set/Map for O(1) lookups
js-tosorted-immutable - Use toSorted() for immutability
8. Advanced Patterns (LOW)
advanced-event-handler-refs - Store event handlers in refs
advanced-use-latest - useLatest for stable callback refs
advanced-init-once - Initialize expensive objects only once with useRef
How to Use
For the complete guide with all 57 rules fully expanded with code examples, see:
references/react-performance-rules.md
Each rule contains:
Brief explanation of why it matters
Incorrect code example with explanation
Correct code example with explanation
Additional context and references
1---2name: react-best-practices3description: <!-- AUTO-GENERATED by export-skills.py — DO NOT EDIT -->4---5<!-- AUTO-GENERATED by export-skills.py — DO NOT EDIT -->6---7name: react-best-practices8description: Vercel's React and Next.js performance optimization guide with 57 rules across 8 categories. Use when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance, bundle size, and rendering efficiency.9tags: [react, performance, nextjs]10---1112# Vercel React Best Practices1314Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains 57 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.1516## When to Apply1718Reference these guidelines when:19- Writing new React components or Next.js pages20- Implementing data fetching (client or server-side)21- Reviewing code for performance issues22- Refactoring existing React/Next.js code23- Optimizing bundle size or load times2425## Rule Categories by Priority2627| Priority | Category | Impact | Prefix |28|----------|----------|--------|--------|29| 1 | Eliminating Waterfalls | CRITICAL | `async-` |30| 2 | Bundle Size Optimization | CRITICAL | `bundle-` |31| 3 | Server-Side Performance | HIGH | `server-` |32| 4 | Client-Side Data Fetching | MEDIUM-HIGH | `client-` |33| 5 | Re-render Optimization | MEDIUM | `rerender-` |34| 6 | Rendering Performance | MEDIUM | `rendering-` |35| 7 | JavaScript Performance | LOW-MEDIUM | `js-` |36| 8 | Advanced Patterns | LOW | `advanced-` |3738## Quick Reference3940### 1. Eliminating Waterfalls (CRITICAL)4142- `async-defer-await` - Move await into branches where actually used43- `async-parallel` - Use Promise.all() for independent operations44- `async-dependencies` - Use better-all for partial dependencies45- `async-api-routes` - Start promises early, await late in API routes46- `async-suspense-boundaries` - Use Suspense to stream content4748### 2. Bundle Size Optimization (CRITICAL)4950- `bundle-barrel-imports` - Import directly, avoid barrel files51- `bundle-dynamic-imports` - Use next/dynamic for heavy components52- `bundle-defer-third-party` - Load analytics/logging after hydration53- `bundle-conditional` - Load modules only when feature is activated54- `bundle-preload` - Preload on hover/focus for perceived speed5556### 3. Server-Side Performance (HIGH)5758- `server-cache-react` - Use React.cache() for per-request deduplication59- `server-cache-lru` - Use LRU cache for cross-request caching60- `server-serialization` - Minimize data passed to client components61- `server-parallel-fetching` - Restructure components to parallelize fetches62- `server-after-nonblocking` - Use after() for non-blocking operations63- `server-auth-actions` - Validate auth in Server Actions before mutations64- `server-dedup-props` - Deduplicate props passed from server to client6566### 4. Client-Side Data Fetching (MEDIUM-HIGH)6768- `client-swr-dedup` - Use SWR for automatic request deduplication69- `client-event-listeners` - Deduplicate global event listeners70- `client-localstorage-schema` - Version localStorage schemas to handle migrations71- `client-passive-event-listeners` - Use passive event listeners for scroll/touch7273### 5. Re-render Optimization (MEDIUM)7475- `rerender-defer-reads` - Don't subscribe to state only used in callbacks76- `rerender-memo` - Extract expensive work into memoized components77- `rerender-dependencies` - Use primitive dependencies in effects78- `rerender-derived-state` - Subscribe to derived booleans, not raw values79- `rerender-functional-setstate` - Use functional setState for stable callbacks80- `rerender-lazy-state-init` - Pass function to useState for expensive values81- `rerender-transitions` - Use startTransition for non-urgent updates82- `rerender-derived-state-no-effect` - Derive state during render, not in useEffect83- `rerender-memo-with-default-value` - Memoize with default values to avoid re-renders84- `rerender-move-effect-to-event` - Move effect logic to event handlers when possible85- `rerender-simple-expression-in-memo` - Inline simple expressions in useMemo86- `rerender-use-ref-transient-values` - Use useRef for values that don't trigger re-render8788### 6. Rendering Performance (MEDIUM)8990- `rendering-animate-svg-wrapper` - Animate div wrapper, not SVG element91- `rendering-content-visibility` - Use content-visibility for long lists92- `rendering-hoist-jsx` - Extract static JSX outside components93- `rendering-svg-precision` - Reduce SVG coordinate precision94- `rendering-hydration-no-flicker` - Use inline script for client-only data95- `rendering-activity` - Use Activity component for show/hide96- `rendering-conditional-render` - Use ternary, not && for conditionals97- `rendering-hydration-suppress-warning` - Suppress hydration warnings for client-only content98- `rendering-usetransition-loading` - Use useTransition for loading states99100### 7. JavaScript Performance (LOW-MEDIUM)101102- `js-batch-dom-css` - Group CSS changes via classes or cssText103- `js-index-maps` - Build Map for repeated lookups104- `js-cache-property-access` - Cache object properties in loops105- `js-cache-function-results` - Cache function results in module-level Map106- `js-cache-storage` - Cache localStorage/sessionStorage reads107- `js-combine-iterations` - Combine multiple filter/map into one loop108- `js-length-check-first` - Check array length before expensive comparison109- `js-early-exit` - Return early from functions110- `js-hoist-regexp` - Hoist RegExp creation outside loops111- `js-min-max-loop` - Use loop for min/max instead of sort112- `js-set-map-lookups` - Use Set/Map for O(1) lookups113- `js-tosorted-immutable` - Use toSorted() for immutability114115### 8. Advanced Patterns (LOW)116117- `advanced-event-handler-refs` - Store event handlers in refs118- `advanced-use-latest` - useLatest for stable callback refs119- `advanced-init-once` - Initialize expensive objects only once with useRef120121## How to Use122123For the complete guide with all 57 rules fully expanded with code examples, see:124`references/react-performance-rules.md`125126Each rule contains:127- Brief explanation of why it matters128- Incorrect code example with explanation129- Correct code example with explanation130- Additional context and references131132<!-- Source: .faos/custom/skills/frontend/react-best-practices/SKILL.md -->
Run npx skillmds@latest add frank-luongt/react-best-practices in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
<!-- AUTO-GENERATED by export-skills.py — DO NOT EDIT --> It is listed under Web & Frontend on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
frank-luongt (@frank-luongt) published this skill. Their other Agent Skills are listed on their SkillMD profile.