Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains 62 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
For the complete guide with all rules expanded: AGENTS.md
1---2name: react-best-practices-33description: Vercel React Best Practices4---5# Vercel React Best Practices67Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains 62 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.89## When to Apply1011Reference these guidelines when:12- Writing new React components or Next.js pages13- Implementing data fetching (client or server-side)14- Reviewing code for performance issues15- Refactoring existing React/Next.js code16- Optimizing bundle size or load times1718## Rule Categories by Priority1920| Priority | Category | Impact | Prefix |21|----------|----------|--------|--------|22| 1 | Eliminating Waterfalls | CRITICAL | `async-` |23| 2 | Bundle Size Optimization | CRITICAL | `bundle-` |24| 3 | Server-Side Performance | HIGH | `server-` |25| 4 | Client-Side Data Fetching | MEDIUM-HIGH | `client-` |26| 5 | Re-render Optimization | MEDIUM | `rerender-` |27| 6 | Rendering Performance | MEDIUM | `rendering-` |28| 7 | JavaScript Performance | LOW-MEDIUM | `js-` |29| 8 | Advanced Patterns | LOW | `advanced-` |3031## Quick Reference3233### 1. Eliminating Waterfalls (CRITICAL)3435- `async-defer-await` - Move await into branches where actually used36- `async-parallel` - Use Promise.all() for independent operations37- `async-dependencies` - Use better-all for partial dependencies38- `async-api-routes` - Start promises early, await late in API routes39- `async-suspense-boundaries` - Use Suspense to stream content4041### 2. Bundle Size Optimization (CRITICAL)4243- `bundle-barrel-imports` - Import directly, avoid barrel files44- `bundle-dynamic-imports` - Use next/dynamic for heavy components45- `bundle-defer-third-party` - Load analytics/logging after hydration46- `bundle-conditional` - Load modules only when feature is activated47- `bundle-preload` - Preload on hover/focus for perceived speed4849### 3. Server-Side Performance (HIGH)5051- `server-auth-actions` - Authenticate server actions like API routes52- `server-cache-react` - Use React.cache() for per-request deduplication53- `server-cache-lru` - Use LRU cache for cross-request caching54- `server-dedup-props` - Avoid duplicate serialization in RSC props55- `server-hoist-static-io` - Hoist static I/O (fonts, logos) to module level56- `server-serialization` - Minimize data passed to client components57- `server-parallel-fetching` - Restructure components to parallelize fetches58- `server-after-nonblocking` - Use after() for non-blocking operations5960### 4. Client-Side Data Fetching (MEDIUM-HIGH)6162- `client-swr-dedup` - Use SWR for automatic request deduplication63- `client-event-listeners` - Deduplicate global event listeners64- `client-passive-event-listeners` - Use passive listeners for scroll65- `client-localstorage-schema` - Version and minimize localStorage data6667### 5. Re-render Optimization (MEDIUM)6869- `rerender-defer-reads` - Don't subscribe to state only used in callbacks70- `rerender-memo` - Extract expensive work into memoized components71- `rerender-memo-with-default-value` - Hoist default non-primitive props72- `rerender-dependencies` - Use primitive dependencies in effects73- `rerender-derived-state` - Subscribe to derived booleans, not raw values74- `rerender-derived-state-no-effect` - Derive state during render, not effects75- `rerender-functional-setstate` - Use functional setState for stable callbacks76- `rerender-lazy-state-init` - Pass function to useState for expensive values77- `rerender-simple-expression-in-memo` - Avoid memo for simple primitives78- `rerender-move-effect-to-event` - Put interaction logic in event handlers79- `rerender-transitions` - Use startTransition for non-urgent updates80- `rerender-use-ref-transient-values` - Use refs for transient frequent values81- `rerender-no-inline-components` - Don't define components inside components8283### 6. Rendering Performance (MEDIUM)8485- `rendering-animate-svg-wrapper` - Animate div wrapper, not SVG element86- `rendering-content-visibility` - Use content-visibility for long lists87- `rendering-hoist-jsx` - Extract static JSX outside components88- `rendering-svg-precision` - Reduce SVG coordinate precision89- `rendering-hydration-no-flicker` - Use inline script for client-only data90- `rendering-hydration-suppress-warning` - Suppress expected mismatches91- `rendering-activity` - Use Activity component for show/hide92- `rendering-conditional-render` - Use ternary, not && for conditionals93- `rendering-usetransition-loading` - Prefer useTransition for loading state94- `rendering-resource-hints` - Use React DOM resource hints for preloading95- `rendering-script-defer-async` - Use defer or async on script tags9697### 7. JavaScript Performance (LOW-MEDIUM)9899- `js-batch-dom-css` - Group CSS changes via classes or cssText100- `js-index-maps` - Build Map for repeated lookups101- `js-cache-property-access` - Cache object properties in loops102- `js-cache-function-results` - Cache function results in module-level Map103- `js-cache-storage` - Cache localStorage/sessionStorage reads104- `js-combine-iterations` - Combine multiple filter/map into one loop105- `js-length-check-first` - Check array length before expensive comparison106- `js-early-exit` - Return early from functions107- `js-hoist-regexp` - Hoist RegExp creation outside loops108- `js-min-max-loop` - Use loop for min/max instead of sort109- `js-set-map-lookups` - Use Set/Map for O(1) lookups110- `js-tosorted-immutable` - Use toSorted() for immutability111- `js-flatmap-filter` - Use flatMap to map and filter in one pass112113### 8. Advanced Patterns (LOW)114115- `advanced-event-handler-refs` - Store event handlers in refs116- `advanced-init-once` - Initialize app once per app load117- `advanced-use-latest` - useLatest for stable callback refs118119## How to Use120121Read individual rule files for detailed explanations and code examples:122123```124rules/async-parallel.md125rules/bundle-barrel-imports.md126```127128Each rule file contains:129- Brief explanation of why it matters130- Incorrect code example with explanation131- Correct code example with explanation132- Additional context and references133134## Full Compiled Document135136For the complete guide with all rules expanded: `AGENTS.md`
Run npx skillmds@latest add comeonoliver/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.
Vercel React Best Practices 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.
ComeOnOliver (@comeonoliver) published this skill. Their other Agent Skills are listed on their SkillMD profile.