New advertisers: 50% off your first month with code FIRSTMONTHSee slots
secondsky avatar

react-best-practices

Vercel's React and Next.js performance guide packaged as a skill with 57 rules across eight categories.

version
3.12.0
GitHub stars
250
View on GitHub

What it does

  • Adds the react-best-practices skill with 57 rules covering waterfalls, bundle size, server and client components, and re-renders
  • Ranks rule categories by impact, from CRITICAL async waterfall and bundle fixes down to LOW advanced patterns
  • Provides incorrect versus correct code examples for each rule, with a concise SKILL.md and a full AGENTS.md guide
  • Designed for writing, reviewing, or refactoring React and Next.js code, and for debugging hydration errors

React and Next.js performance optimization guidelines from Vercel Engineering. Use when writing/reviewing/refactoring React code for optimal performance. Covers async patterns, bundle optimization, server/client components, re-render optimization.

Add marketplace

/plugin marketplace add secondsky/claude-skills

Run it inside Claude Code once, then install the plugin below.

Install

/plugin install react-best-practices@claude-skills

Run it inside Claude Code after adding the marketplace.

Files

Discovered from source

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

PriorityCategoryImpactPrefix
1Eliminating WaterfallsCRITICALasync-
2Bundle Size OptimizationCRITICALbundle-
3Server-Side PerformanceHIGHserver-
4Client-Side Data FetchingMEDIUM-HIGHclient-
5Re-render OptimizationMEDIUMrerender-
6Rendering PerformanceMEDIUMrendering-
7JavaScript PerformanceLOW-MEDIUMjs-
8Advanced PatternsLOWadvanced-

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

2. Bundle Size Optimization (CRITICAL)

  • bundle-barrel-imports - Import directly, avoid barrel files
  • bundle-dynamic-imports - Use next/dynamic for heavy components
  • bundle-defer-third-party - Load analytics/logging after hydration
  • bundle-conditional - Load modules only when feature is activated
  • bundle-preload - Preload on hover/focus for perceived speed

3. Server-Side Performance (HIGH)

  • server-cache-react - Use React.cache() for per-request deduplication
  • server-cache-lru - Use LRU cache for cross-request caching
  • server-serialization - Minimize data passed to client components
  • server-parallel-fetching - Restructure components to parallelize fetches
  • server-after-nonblocking - Use after() for non-blocking operations
  • server-auth-actions - Authenticate server actions like API routes
  • server-dedup-props - Avoid duplicate serialization in RSC props

4. Client-Side Data Fetching (MEDIUM-HIGH)

  • client-swr-dedup - Use SWR for automatic request deduplication
  • client-event-listeners - Deduplicate global event listeners

5. Re-render Optimization (MEDIUM)

  • rerender-defer-reads - Don't subscribe to state only used in callbacks
  • rerender-memo - Extract expensive work into memoized components
  • rerender-dependencies - Use primitive dependencies in effects
  • rerender-derived-state - Subscribe to derived booleans, not raw values
  • rerender-functional-setstate - Use functional setState for stable callbacks
  • rerender-lazy-state-init - Pass function to useState for expensive values
  • rerender-transitions - Use startTransition for non-urgent updates
  • rerender-memo-with-default-value - Hoist default non-primitive props
  • rerender-derived-state-no-effect - Derive state during render, not effects
  • rerender-simple-expression-in-memo - Avoid memo for simple primitives
  • rerender-move-effect-to-event - Put interaction logic in event handlers
  • rerender-use-ref-transient-values - Use refs for transient frequent values

6. Rendering Performance (MEDIUM)

  • rendering-animate-svg-wrapper - Animate div wrapper, not SVG element
  • rendering-content-visibility - Use content-visibility for long lists
  • rendering-hoist-jsx - Extract static JSX outside components
  • rendering-svg-precision - Reduce SVG coordinate precision
  • rendering-hydration-no-flicker - Use inline script for client-only data
  • rendering-activity - Use Activity component for show/hide
  • rendering-conditional-render - Use ternary, not && for conditionals
  • rendering-hydration-suppress-warning - Suppress expected mismatches
  • rendering-usetransition-loading - Prefer useTransition for loading state

7. JavaScript Performance (LOW-MEDIUM)

  • js-batch-dom-css - Group CSS changes via classes or cssText
  • js-index-maps - Build Map for repeated lookups
  • js-cache-property-access - Cache object properties in loops
  • js-cache-function-results - Cache function results in module-level Map
  • js-cache-storage - Cache localStorage/sessionStorage reads
  • js-combine-iterations - Combine multiple filter/map into one loop
  • js-length-check-first - Check array length before expensive comparison
  • js-early-exit - Return early from functions
  • js-hoist-regexp - Hoist RegExp creation outside loops
  • 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 app once per app load

How to Use

Read individual rule files for detailed explanations and code examples:

rules/async-parallel.md
rules/bundle-barrel-imports.md
rules/_sections.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

Readme

React Best Practices

Status: ✅ Production Ready Version: 1.0.0 (Vercel source) Last Updated: 2026-01-28

Comprehensive React and Next.js performance optimization guide from Vercel Engineering, containing 57 rules across 8 categories.

What This Skill Provides

✅ Eliminating Waterfalls (CRITICAL) - 5 rules for async optimization ✅ Bundle Size Optimization (CRITICAL) - 5 rules for reducing bundle size ✅ Server-Side Performance (HIGH) - 7 rules for SSR optimization ✅ Client-Side Data Fetching (MEDIUM-HIGH) - 2 rules for client optimization ✅ Re-render Optimization (MEDIUM) - 12 rules for preventing unnecessary renders ✅ Rendering Performance (MEDIUM) - 9 rules for efficient rendering ✅ JavaScript Performance (LOW-MEDIUM) - 14 rules for JS optimization ✅ Advanced Patterns (LOW) - 3 rules for advanced techniques

Total: 57 production-tested rules with incorrect vs correct examples

When to Use This Skill

Use this skill when:

  • Writing new React components or Next.js pages
  • Reviewing code for performance issues
  • Refactoring existing React/Next.js applications
  • Optimizing bundle size or load times
  • Debugging hydration errors, re-render issues, or memory leaks
  • Implementing async patterns, server components, or streaming

Structure

  • SKILL.md - Concise overview with rule categories (~1,500 words)
  • AGENTS.md - Full compiled guide with all rules expanded (~40,000 words)
  • rules/ - 57 individual rule files for granular reference
  • metadata.json - Version and attribution metadata

Attribution

This skill packages Vercel's React Best Practices guide for Claude Code.

Original Author: @shuding (Vercel Engineering) Source: https://github.com/vercel-labs/agent-skills/tree/main/skills/react-best-practices Packaging: Claude Skills Maintainers License: MIT

We are grateful to Vercel for creating and open-sourcing this comprehensive guide.

Installation

# Add the marketplace once (if not already added)
/plugin marketplace add https://github.com/secondsky/claude-skills

# Install this plugin
/plugin install react-best-practices@claude-skills

Usage Examples

Example 1: Optimize Re-renders

Ask: "How can I prevent unnecessary re-renders in my React component?"

Claude will:

  • Reference SKILL.md re-render optimization section
  • Suggest memo, useMemo, useCallback patterns
  • Provide code examples from rules/

Example 2: Reduce Bundle Size

Ask: "My React bundle is too large, help me reduce it"

Claude will:

  • Reference bundle optimization rules
  • Suggest dynamic imports, tree-shaking, direct imports
  • Show examples from rules/bundle-*.md

Example 3: Fix Hydration Errors

Ask: "I'm getting hydration mismatches in Next.js"

Claude will:

  • Reference hydration and server component patterns
  • Explain common causes and solutions
  • Point to specific rules/rendering-hydration-no-flicker.md

Progressive Disclosure

SKILL.md (auto-loaded): Quick reference, rule categories, top errors AGENTS.md (on request): Full guide with all 57 rules expanded rules/ (on request): Individual rule files for specific topics

Ask Claude to "Load AGENTS.md" for the comprehensive guide.

Related Skills

  • nextjs - Next.js framework patterns
  • tanstack-query - Data fetching optimization
  • react-hook-form-zod - Form validation patterns
  • zustand-state-management - State management
  • tailwind-v4-shadcn - UI component styling

Support

Details

Marketplace
secondsky/claude-skills
Source
plugins/react-best-practices
Category
Frontend
Keywords
react-best-practices, react, best, practices, frontend, components, refactoring, async
Listed since
Apr 7, 2026

More from secondsky/claude-skills

All 122

Similar to react-best-practices

More Frontend & UI Code