React best practices

From laguagu/claude-code-nextjs-skills · View interactive version

React best practices is an AI agent skill from the GitHub repository laguagu/claude-code-nextjs-skills. React and Next.js performance optimization guide from Vercel Engineering (70 rules in 8 categories). Use when writing, reviewing, or refactoring React/Next.js code to eliminate waterfalls, reduce bundle size, prevent re-renders, optimize Server Components, or fix performance bottlenecks. Triggers on

How to use this skill

Skill file

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.

Version Compatibility

| Feature | Minimum version |

|---------|-----------------|

| Core performance rules (async, bundle, js) | React 18 + Next.js 14 |

| React.cache() (server-cache-react) | React 19 |

| <Activity> (rendering-activity) | React 19.2 |

| useEffectEvent (advanced-effect-event-deps, advanced-use-latest, advanced-event-handler-refs) | React 19.2 |

| after() (server-after-nonblocking) | Next.js 15.1 |

| use(), async transitions, resource hints (async-suspense-boundaries, rendering-usetransition-loading, rendering-resource-hints) | React 19 |

| React Compiler (affects rerender-* rules) | React 17/18/19; older versions need the matching target and runtime |

| use cache directive (see cache-components skill) | Next.js 16 |

When to Apply

Reference these guidelines when:

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- |

Profile before applying low-level JavaScript rules. They are candidates for measured

hot paths, not a checklist for rewriting clear code. With React Compiler enabled,

check its coverage before adding manual memoization.

Quick Reference

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)

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:

Full Compiled Document

For the complete guide with all rules expanded: AGENTS.md

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.