vercel-react-best-practices
vercel-labs/agent-skills
70 React/Next.js performance rules from Vercel Engineering, prioritized by impact for writing, reviewing, and refactoring code.
What is vercel-react-best-practices?
vercel-react-best-practices installs a structured set of 70 performance optimization rules for React and Next.js, organized into 8 priority tiers from CRITICAL (waterfall elimination, bundle size) to LOW (advanced patterns). Each rule includes a rationale, a bad code example, and a correct code example. The skill is designed to guide coding agents when generating new components, reviewing existing code, or refactoring for performance.
- Provides 70 named, prefixed rules covering React and Next.js performance across 8 categories
- Prioritizes rules by impact level (CRITICAL → LOW) so agents tackle the highest-value issues first
- Covers waterfall elimination using Promise.all, Suspense, and deferred awaits
- Addresses bundle size via dynamic imports, direct imports, and deferred third-party loading
- Guides server-side patterns including React.cache(), LRU caching, and RSC serialization
- Covers client-side re-render optimization, rendering performance, and JavaScript micro-optimizations
How to install vercel-react-best-practices
npx skills add https://github.com/vercel-labs/agent-skills --skill vercel-react-best-practices- Project must use React (any version supporting hooks) or Next.js
- Coding agent must support SKILL.md-based skill installation (e.g., Claude Code, Cursor)
- Node.js and npx available to run the install command
- Familiarity with React hooks and Next.js App Router is helpful for interpreting rules
How to use vercel-react-best-practices
- 1.Install the skill: npx skills add https://github.com/vercel-labs/agent-skills --skill vercel-react-best-practices
- 2.Ask your coding agent to write, review, or refactor a React or Next.js file — the skill triggers automatically on relevant tasks
- 3.Reference a specific rule by name (e.g., 'apply async-parallel') to target a particular optimization
- 4.Read individual rule files under rules/<rule-name>.md for detailed explanations and code examples
- 5.Consult AGENTS.md for the full compiled guide with all 70 rules expanded
- 6.Use rule prefixes (async-, bundle-, server-, etc.) to scope agent instructions to a category
- 7.Prioritize CRITICAL-tier rules (async- and bundle-) first when doing a broad performance pass
- 8.Combine with bundle analysis tools to validate bundle-* rule improvements
Use cases
- Writing new Next.js pages or React components that need to follow performance best practices
- Reviewing a pull request for common React performance anti-patterns
- Refactoring data fetching code to eliminate request waterfalls
- Reducing JavaScript bundle size by replacing barrel imports or adding dynamic imports
- Optimizing re-render behavior using memoization, refs, and derived state patterns
- Frontend engineers building React or Next.js applications
- Coding agents (Claude Code, Cursor) tasked with generating or reviewing React/Next.js code
- Teams adopting Vercel infrastructure who want opinionated, Vercel-aligned patterns
- Developers preparing for performance audits or Core Web Vitals improvements
- Tech leads setting automated code review standards for React projects
vercel-react-best-practices FAQ
It provides guidelines that coding agents reference when generating or reviewing code. Enforcement depends on how the agent is prompted — it does not add linting or CI checks automatically.
Each rule has its own file at rules/<rule-name>.md (e.g., rules/async-parallel.md) containing the rationale, a bad example, and a correct example. The full compiled document is in AGENTS.md.
The skill content covers both, but several rules (RSC props, React.cache, server actions, after()) are specific to the App Router and React Server Components.
There are 70 rules across 8 categories, each with a short prefix (async-, bundle-, server-, client-, rerender-, rendering-, js-, advanced-) and an assigned impact level from CRITICAL to LOW.
Yes. The rules apply to any React or Next.js project. Some server-side rules (e.g., after()) may rely on Vercel-specific APIs, but the majority are framework-level patterns usable anywhere.
Full instructions (SKILL.md)
Source of truth, from vercel-labs/agent-skills.
name: vercel-react-best-practices description: React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements. license: MIT metadata: author: vercel version: "1.0.0"
Vercel React Best Practices
Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains 70 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-cheap-condition-before-await- Check cheap sync conditions before awaiting flags or remote valuesasync-defer-await- Move await into branches where actually usedasync-parallel- Use Promise.all() for independent operationsasync-dependencies- Use better-all for partial dependenciesasync-api-routes- Start promises early, await late in API routesasync-suspense-boundaries- Use Suspense to stream content
2. Bundle Size Optimization (CRITICAL)
bundle-barrel-imports- Import directly, avoid barrel filesbundle-analyzable-paths- Prefer statically analyzable import and file-system paths to avoid broad bundles and tracesbundle-dynamic-imports- Use next/dynamic for heavy componentsbundle-defer-third-party- Load analytics/logging after hydrationbundle-conditional- Load modules only when feature is activatedbundle-preload- Preload on hover/focus for perceived speed
3. Server-Side Performance (HIGH)
server-auth-actions- Authenticate server actions like API routesserver-cache-react- Use React.cache() for per-request deduplicationserver-cache-lru- Use LRU cache for cross-request cachingserver-dedup-props- Avoid duplicate serialization in RSC propsserver-hoist-static-io- Hoist static I/O (fonts, logos) to module levelserver-no-shared-module-state- Avoid module-level mutable request state in RSC/SSRserver-serialization- Minimize data passed to client componentsserver-parallel-fetching- Restructure components to parallelize fetchesserver-parallel-nested-fetching- Chain nested fetches per item in Promise.allserver-after-nonblocking- Use after() for non-blocking operations
4. Client-Side Data Fetching (MEDIUM-HIGH)
client-swr-dedup- Use SWR for automatic request deduplicationclient-event-listeners- Deduplicate global event listenersclient-passive-event-listeners- Use passive listeners for scrollclient-localstorage-schema- Version and minimize localStorage data
5. Re-render Optimization (MEDIUM)
rerender-defer-reads- Don't subscribe to state only used in callbacksrerender-memo- Extract expensive work into memoized componentsrerender-memo-with-default-value- Hoist default non-primitive propsrerender-dependencies- Use primitive dependencies in effectsrerender-derived-state- Subscribe to derived booleans, not raw valuesrerender-derived-state-no-effect- Derive state during render, not effectsrerender-functional-setstate- Use functional setState for stable callbacksrerender-lazy-state-init- Pass function to useState for expensive valuesrerender-simple-expression-in-memo- Avoid memo for simple primitivesrerender-split-combined-hooks- Split hooks with independent dependenciesrerender-move-effect-to-event- Put interaction logic in event handlersrerender-transitions- Use startTransition for non-urgent updatesrerender-use-deferred-value- Defer expensive renders to keep input responsivererender-use-ref-transient-values- Use refs for transient frequent valuesrerender-no-inline-components- Don't define components inside components
6. Rendering Performance (MEDIUM)
rendering-animate-svg-wrapper- Animate div wrapper, not SVG elementrendering-content-visibility- Use content-visibility for long listsrendering-hoist-jsx- Extract static JSX outside componentsrendering-svg-precision- Reduce SVG coordinate precisionrendering-hydration-no-flicker- Use inline script for client-only datarendering-hydration-suppress-warning- Suppress expected mismatchesrendering-activity- Use Activity component for show/hiderendering-conditional-render- Use ternary, not && for conditionalsrendering-usetransition-loading- Prefer useTransition for loading staterendering-resource-hints- Use React DOM resource hints for preloadingrendering-script-defer-async- Use defer or async on script tags
7. JavaScript Performance (LOW-MEDIUM)
js-batch-dom-css- Group CSS changes via classes or cssTextjs-index-maps- Build Map for repeated lookupsjs-cache-property-access- Cache object properties in loopsjs-cache-function-results- Cache function results in module-level Mapjs-cache-storage- Cache localStorage/sessionStorage readsjs-combine-iterations- Combine multiple filter/map into one loopjs-length-check-first- Check array length before expensive comparisonjs-early-exit- Return early from functionsjs-hoist-regexp- Hoist RegExp creation outside loopsjs-min-max-loop- Use loop for min/max instead of sortjs-set-map-lookups- Use Set/Map for O(1) lookupsjs-tosorted-immutable- Use toSorted() for immutabilityjs-flatmap-filter- Use flatMap to map and filter in one passjs-request-idle-callback- Defer non-critical work to browser idle time
8. Advanced Patterns (LOW)
advanced-effect-event-deps- Don't putuseEffectEventresults in effect depsadvanced-event-handler-refs- Store event handlers in refsadvanced-init-once- Initialize app once per app loadadvanced-use-latest- useLatest for stable callback refs
How to Use
Read individual rule files for detailed explanations and code examples:
rules/async-parallel.md
rules/bundle-barrel-imports.md
Each rule file contains:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Additional context and references
Full Compiled Document
For the complete guide with all rules expanded: AGENTS.md
Related skills
More from vercel-labs/agent-skills and the wider catalog.
web-design-guidelines
Review UI code against Web Interface Guidelines for accessibility, UX, and design best practices
vercel-composition-patterns
React composition patterns to scale components without boolean prop proliferation.
vercel-react-native-skills
React Native and Expo best practices for performant mobile apps, animations, and native integrations.
deploy-to-vercel
Deploy applications to Vercel with git integration or direct CLI deployment.
vercel-react-view-transitions
Implement smooth, native-feeling animations using React's View Transition API without third-party libraries.
vercel-cli-with-tokens
Deploy and manage Vercel projects using token-based authentication without interactive login.