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.
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-practices-33description: <!-- 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.9---1011# Vercel React Best Practices1213Comprehensive 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.1415## When to Apply1617Reference these guidelines when:18- Writing new React components or Next.js pages19- Implementing data fetching (client or server-side)20- Reviewing code for performance issues21- Refactoring existing React/Next.js code22- Optimizing bundle size or load times2324## Rule Categories by Priority2526| Priority | Category | Impact | Prefix |27|----------|----------|--------|--------|28| 1 | Eliminating Waterfalls | CRITICAL | `async-` |29| 2 | Bundle Size Optimization | CRITICAL | `bundle-` |30| 3 | Server-Side Performance | HIGH | `server-` |31| 4 | Client-Side Data Fetching | MEDIUM-HIGH | `client-` |32| 5 | Re-render Optimization | MEDIUM | `rerender-` |33| 6 | Rendering Performance | MEDIUM | `rendering-` |34| 7 | JavaScript Performance | LOW-MEDIUM | `js-` |35| 8 | Advanced Patterns | LOW | `advanced-` |3637## Quick Reference3839### 1. Eliminating Waterfalls (CRITICAL)4041- `async-defer-await` - Move await into branches where actually used42- `async-parallel` - Use Promise.all() for independent operations43- `async-dependencies` - Use better-all for partial dependencies44- `async-api-routes` - Start promises early, await late in API routes45- `async-suspense-boundaries` - Use Suspense to stream content4647### 2. Bundle Size Optimization (CRITICAL)4849- `bundle-barrel-imports` - Import directly, avoid barrel files50- `bundle-dynamic-imports` - Use next/dynamic for heavy components51- `bundle-defer-third-party` - Load analytics/logging after hydration52- `bundle-conditional` - Load modules only when feature is activated53- `bundle-preload` - Preload on hover/focus for perceived speed5455### 3. Server-Side Performance (HIGH)5657- `server-cache-react` - Use React.cache() for per-request deduplication58- `server-cache-lru` - Use LRU cache for cross-request caching59- `server-serialization` - Minimize data passed to client components60- `server-parallel-fetching` - Restructure components to parallelize fetches61- `server-after-nonblocking` - Use after() for non-blocking operations62- `server-auth-actions` - Validate auth in Server Actions before mutations63- `server-dedup-props` - Deduplicate props passed from server to client6465### 4. Client-Side Data Fetching (MEDIUM-HIGH)6667- `client-swr-dedup` - Use SWR for automatic request deduplication68- `client-event-listeners` - Deduplicate global event listeners69- `client-localstorage-schema` - Version localStorage schemas to handle migrations70- `client-passive-event-listeners` - Use passive event listeners for scroll/touch7172### 5. Re-render Optimization (MEDIUM)7374- `rerender-defer-reads` - Don't subscribe to state only used in callbacks75- `rerender-memo` - Extract expensive work into memoized components76- `rerender-dependencies` - Use primitive dependencies in effects77- `rerender-derived-state` - Subscribe to derived booleans, not raw values78- `rerender-functional-setstate` - Use functional setState for stable callbacks79- `rerender-lazy-state-init` - Pass function to useState for expensive values80- `rerender-transitions` - Use startTransition for non-urgent updates81- `rerender-derived-state-no-effect` - Derive state during render, not in useEffect82- `rerender-memo-with-default-value` - Memoize with default values to avoid re-renders83- `rerender-move-effect-to-event` - Move effect logic to event handlers when possible84- `rerender-simple-expression-in-memo` - Inline simple expressions in useMemo85- `rerender-use-ref-transient-values` - Use useRef for values that don't trigger re-render8687### 6. Rendering Performance (MEDIUM)8889- `rendering-animate-svg-wrapper` - Animate div wrapper, not SVG element90- `rendering-content-visibility` - Use content-visibility for long lists91- `rendering-hoist-jsx` - Extract static JSX outside components92- `rendering-svg-precision` - Reduce SVG coordinate precision93- `rendering-hydration-no-flicker` - Use inline script for client-only data94- `rendering-activity` - Use Activity component for show/hide95- `rendering-conditional-render` - Use ternary, not && for conditionals96- `rendering-hydration-suppress-warning` - Suppress hydration warnings for client-only content97- `rendering-usetransition-loading` - Use useTransition for loading states9899### 7. JavaScript Performance (LOW-MEDIUM)100101- `js-batch-dom-css` - Group CSS changes via classes or cssText102- `js-index-maps` - Build Map for repeated lookups103- `js-cache-property-access` - Cache object properties in loops104- `js-cache-function-results` - Cache function results in module-level Map105- `js-cache-storage` - Cache localStorage/sessionStorage reads106- `js-combine-iterations` - Combine multiple filter/map into one loop107- `js-length-check-first` - Check array length before expensive comparison108- `js-early-exit` - Return early from functions109- `js-hoist-regexp` - Hoist RegExp creation outside loops110- `js-min-max-loop` - Use loop for min/max instead of sort111- `js-set-map-lookups` - Use Set/Map for O(1) lookups112- `js-tosorted-immutable` - Use toSorted() for immutability113114### 8. Advanced Patterns (LOW)115116- `advanced-event-handler-refs` - Store event handlers in refs117- `advanced-use-latest` - useLatest for stable callback refs118- `advanced-init-once` - Initialize expensive objects only once with useRef119120## How to Use121122For the complete guide with all 57 rules fully expanded with code examples, see:123`references/react-performance-rules.md`124125Each rule contains:126- Brief explanation of why it matters127- Incorrect code example with explanation128- Correct code example with explanation129- Additional context and references130131<!-- Source: .faos/custom/skills/frontend/react-best-practices/SKILL.md -->
Run npx skillmds@latest add frank-luongt/react-best-practices-3 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. Independent scanners report: SkillSpector: CAUTION, Skill Scanner: PASS. 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.