Awesome-vibe-coding react-best-practices
React and Next.js performance optimization guidelines from Vercel Engineering. Use when writing, reviewing, or refactoring React/Next.js code — components, data fetching, bundle size, or performance.
install
source · Clone the upstream repo
git clone https://github.com/adriannoes/awesome-vibe-coding
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/adriannoes/awesome-vibe-coding "$T" && mkdir -p ~/.claude/skills && cp -r "$T/cursor/skills/react-best-practices" ~/.claude/skills/adriannoes-awesome-vibe-coding-react-best-practices && rm -rf "$T"
manifest:
cursor/skills/react-best-practices/SKILL.mdsource content
Source: vercel-labs/agent-skills —
skills/react-best-practices/ (MIT). Rule markdown files and AGENTS.md remain upstream; this file is a portable summary. Refresh from upstream periodically or run npx skills add vercel-labs/agent-skills.
Vercel React Best Practices
Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains 69 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 | |
| 2 | Bundle Size Optimization | CRITICAL | |
| 3 | Server-Side Performance | HIGH | |
| 4 | Client-Side Data Fetching | MEDIUM-HIGH | |
| 5 | Re-render Optimization | MEDIUM | |
| 6 | Rendering Performance | MEDIUM | |
| 7 | JavaScript Performance | LOW-MEDIUM | |
| 8 | Advanced Patterns | LOW | |
Quick Reference
1. Eliminating Waterfalls (CRITICAL)
- Check cheap sync conditions before awaiting flags or remote valuesasync-cheap-condition-before-await
- Move await into branches where actually usedasync-defer-await
- Use Promise.all() for independent operationsasync-parallel
- Use better-all for partial dependenciesasync-dependencies
- Start promises early, await late in API routesasync-api-routes
- Use Suspense to stream contentasync-suspense-boundaries
2. Bundle Size Optimization (CRITICAL)
- Import directly, avoid barrel filesbundle-barrel-imports
- Use next/dynamic for heavy componentsbundle-dynamic-imports
- Load analytics/logging after hydrationbundle-defer-third-party
- Load modules only when feature is activatedbundle-conditional
- Preload on hover/focus for perceived speedbundle-preload
3. Server-Side Performance (HIGH)
- Authenticate server actions like API routesserver-auth-actions
- Use React.cache() for per-request deduplicationserver-cache-react
- Use LRU cache for cross-request cachingserver-cache-lru
- Avoid duplicate serialization in RSC propsserver-dedup-props
- Hoist static I/O (fonts, logos) to module levelserver-hoist-static-io
- Avoid module-level mutable request state in RSC/SSRserver-no-shared-module-state
- Minimize data passed to client componentsserver-serialization
- Restructure components to parallelize fetchesserver-parallel-fetching
- Chain nested fetches per item in Promise.allserver-parallel-nested-fetching
- Use after() for non-blocking operationsserver-after-nonblocking
4. Client-Side Data Fetching (MEDIUM-HIGH)
- Use SWR for automatic request deduplicationclient-swr-dedup
- Deduplicate global event listenersclient-event-listeners
- Use passive listeners for scrollclient-passive-event-listeners
- Version and minimize localStorage dataclient-localstorage-schema
5. Re-render Optimization (MEDIUM)
- Don't subscribe to state only used in callbacksrerender-defer-reads
- Extract expensive work into memoized componentsrerender-memo
- Hoist default non-primitive propsrerender-memo-with-default-value
- Use primitive dependencies in effectsrerender-dependencies
- Subscribe to derived booleans, not raw valuesrerender-derived-state
- Derive state during render, not effectsrerender-derived-state-no-effect
- Use functional setState for stable callbacksrerender-functional-setstate
- Pass function to useState for expensive valuesrerender-lazy-state-init
- Avoid memo for simple primitivesrerender-simple-expression-in-memo
- Split hooks with independent dependenciesrerender-split-combined-hooks
- Put interaction logic in event handlersrerender-move-effect-to-event
- Use startTransition for non-urgent updatesrerender-transitions
- Defer expensive renders to keep input responsivererender-use-deferred-value
- Use refs for transient frequent valuesrerender-use-ref-transient-values
- Don't define components inside componentsrerender-no-inline-components
6. Rendering Performance (MEDIUM)
- Animate div wrapper, not SVG elementrendering-animate-svg-wrapper
- Use content-visibility for long listsrendering-content-visibility
- Extract static JSX outside componentsrendering-hoist-jsx
- Reduce SVG coordinate precisionrendering-svg-precision
- Use inline script for client-only datarendering-hydration-no-flicker
- Suppress expected mismatchesrendering-hydration-suppress-warning
- Use Activity component for show/hiderendering-activity
- Use ternary, not && for conditionalsrendering-conditional-render
- Prefer useTransition for loading staterendering-usetransition-loading
- Use React DOM resource hints for preloadingrendering-resource-hints
- Use defer or async on script tagsrendering-script-defer-async
7. JavaScript Performance (LOW-MEDIUM)
- Group CSS changes via classes or cssTextjs-batch-dom-css
- Build Map for repeated lookupsjs-index-maps
- Cache object properties in loopsjs-cache-property-access
- Cache function results in module-level Mapjs-cache-function-results
- Cache localStorage/sessionStorage readsjs-cache-storage
- Combine multiple filter/map into one loopjs-combine-iterations
- Check array length before expensive comparisonjs-length-check-first
- Return early from functionsjs-early-exit
- Hoist RegExp creation outside loopsjs-hoist-regexp
- Use loop for min/max instead of sortjs-min-max-loop
- Use Set/Map for O(1) lookupsjs-set-map-lookups
- Use toSorted() for immutabilityjs-tosorted-immutable
- Use flatMap to map and filter in one passjs-flatmap-filter
- Defer non-critical work to browser idle timejs-request-idle-callback
8. Advanced Patterns (LOW)
- Don't putadvanced-effect-event-deps
results in effect depsuseEffectEvent
- Store event handlers in refsadvanced-event-handler-refs
- Initialize app once per app loadadvanced-init-once
- useLatest for stable callback refsadvanced-use-latest
How to Use (full detail upstream)
Rule files with incorrect/correct examples are not copied into this repo. Open or fetch them from:
- Directory (browse on GitHub): https://github.com/vercel-labs/agent-skills/tree/main/skills/react-best-practices/rules
- Raw rule file:
(replacehttps://raw.githubusercontent.com/vercel-labs/agent-skills/main/skills/react-best-practices/rules/<rule-id>.md
with IDs listed above, e.g.<rule-id>
)async-parallel.md - Compiled guide (all rules expanded): https://raw.githubusercontent.com/vercel-labs/agent-skills/main/skills/react-best-practices/AGENTS.md