React Performance Optimization

Vercel react best practices

by CloudAI-X · MIT license · ★ 1,416 on GitHub

Vercel react best practices cover

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.

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

# Vercel React Best Practices

### When to Load

- **Trigger**: React or Next.js development, component writing, data fetching patterns, bundle optimization
- **Skip**: Project does not use React or Next.js

Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains 47 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.

## When to Apply

Reference these guidelines when:

Overview

Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains 47 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.

Manual install (npx, ZIP)
Claude Codenpx skills add CloudAI-X/claude-workflow-v2 --skill vercel-react-best-practices -g -a claude-code
Claude Code (degit)npx degit CloudAI-X/claude-workflow-v2/skills/vercel-react-best-practices#main ~/.claude/skills/vercel-react-best-practices
Claude.ai / desktopZip the folder and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md5.4 KB
Read SKILL.md here
CloudAI-X/main1 file shown
SKILL.md
Show the full text119 lines

Vercel React Best Practices

When to Load
  • Trigger: React or Next.js development, component writing, data fetching patterns, bundle optimization
  • Skip: Project does not use React or Next.js

Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains 47 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
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
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
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
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

Full Compiled Document

For the complete guide with all rules expanded and detailed code examples, see AGENTS.md.

Each rule contains:

  • Brief explanation of why it matters
  • Incorrect code example with explanation
  • Correct code example with explanation
  • Additional context and references
1---
2name: vercel-react-best-practices
3description: 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.
4---
5 
6# Vercel React Best Practices
7 
8### When to Load
9 
10- **Trigger**: React or Next.js development, component writing, data fetching patterns, bundle optimization
11- **Skip**: Project does not use React or Next.js
12 
13Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains 47 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.
14 
15## When to Apply
16 
17Reference these guidelines when:
18 
19- Writing new React components or Next.js pages
20- Implementing data fetching (client or server-side)
21- Reviewing code for performance issues
22- Refactoring existing React/Next.js code
23- Optimizing bundle size or load times
24 
25## Rule Categories by Priority
26 
27| Priority | Category | Impact | Prefix |
28| -------- | ------------------------- | ----------- | ------------ |
29| 1 | Eliminating Waterfalls | CRITICAL | `async-` |
30| 2 | Bundle Size Optimization | CRITICAL | `bundle-` |
31| 3 | Server-Side Performance | HIGH | `server-` |
32| 4 | Client-Side Data Fetching | MEDIUM-HIGH | `client-` |
33| 5 | Re-render Optimization | MEDIUM | `rerender-` |
34| 6 | Rendering Performance | MEDIUM | `rendering-` |
35| 7 | JavaScript Performance | LOW-MEDIUM | `js-` |
36| 8 | Advanced Patterns | LOW | `advanced-` |
37 
38## Quick Reference
39 
40### 1. Eliminating Waterfalls (CRITICAL)
41 
42- `async-defer-await` - Move await into branches where actually used
43- `async-parallel` - Use Promise.all() for independent operations
44- `async-dependencies` - Use better-all for partial dependencies
45- `async-api-routes` - Start promises early, await late in API routes
46- `async-suspense-boundaries` - Use Suspense to stream content
47 
48### 2. Bundle Size Optimization (CRITICAL)
49 
50- `bundle-barrel-imports` - Import directly, avoid barrel files
51- `bundle-dynamic-imports` - Use next/dynamic for heavy components
52- `bundle-defer-third-party` - Load analytics/logging after hydration
53- `bundle-conditional` - Load modules only when feature is activated
54- `bundle-preload` - Preload on hover/focus for perceived speed
55 
56### 3. Server-Side Performance (HIGH)
57 
58- `server-cache-react` - Use React.cache() for per-request deduplication
59- `server-cache-lru` - Use LRU cache for cross-request caching
60- `server-serialization` - Minimize data passed to client components
61- `server-parallel-fetching` - Restructure components to parallelize fetches
62- `server-after-nonblocking` - Use after() for non-blocking operations
63 
64### 4. Client-Side Data Fetching (MEDIUM-HIGH)
65 
66- `client-swr-dedup` - Use SWR for automatic request deduplication
67- `client-event-listeners` - Deduplicate global event listeners
68 
69### 5. Re-render Optimization (MEDIUM)
70 
71- `rerender-defer-reads` - Don't subscribe to state only used in callbacks
72- `rerender-memo` - Extract expensive work into memoized components
73- `rerender-dependencies` - Use primitive dependencies in effects
74- `rerender-derived-state` - Subscribe to derived booleans, not raw values
75- `rerender-functional-setstate` - Use functional setState for stable callbacks
76- `rerender-lazy-state-init` - Pass function to useState for expensive values
77- `rerender-transitions` - Use startTransition for non-urgent updates
78 
79### 6. Rendering Performance (MEDIUM)
80 
81- `rendering-animate-svg-wrapper` - Animate div wrapper, not SVG element
82- `rendering-content-visibility` - Use content-visibility for long lists
83- `rendering-hoist-jsx` - Extract static JSX outside components
84- `rendering-svg-precision` - Reduce SVG coordinate precision
85- `rendering-hydration-no-flicker` - Use inline script for client-only data
86- `rendering-activity` - Use Activity component for show/hide
87- `rendering-conditional-render` - Use ternary, not && for conditionals
88 
89### 7. JavaScript Performance (LOW-MEDIUM)
90 
91- `js-batch-dom-css` - Group CSS changes via classes or cssText
92- `js-index-maps` - Build Map for repeated lookups
93- `js-cache-property-access` - Cache object properties in loops
94- `js-cache-function-results` - Cache function results in module-level Map
95- `js-cache-storage` - Cache localStorage/sessionStorage reads
96- `js-combine-iterations` - Combine multiple filter/map into one loop
97- `js-length-check-first` - Check array length before expensive comparison
98- `js-early-exit` - Return early from functions
99- `js-hoist-regexp` - Hoist RegExp creation outside loops
100- `js-min-max-loop` - Use loop for min/max instead of sort
101- `js-set-map-lookups` - Use Set/Map for O(1) lookups
102- `js-tosorted-immutable` - Use toSorted() for immutability
103 
104### 8. Advanced Patterns (LOW)
105 
106- `advanced-event-handler-refs` - Store event handlers in refs
107- `advanced-use-latest` - useLatest for stable callback refs
108 
109## Full Compiled Document
110 
111For the complete guide with all rules expanded and detailed code examples, see [AGENTS.md](AGENTS.md).
112 
113Each rule contains:
114 
115- Brief explanation of why it matters
116- Incorrect code example with explanation
117- Correct code example with explanation
118- Additional context and references
119 
View all files on GitHub →

Details

License
MIT
Stars on the repo
★ 1,416
Checked
Source
CloudAI-X/claude-workflow-v2 ↗
Creator
CloudAI-X · 14 listings
View creator

Similar skills

See all →
Skillshadcn/uishadcn-ui/ui · by shadcn-uiManages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI, including chat interfaces. Provides project context, component docs, and usage examples. Applies when working with shadcn/ui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for "shadcn init", "create an app with --preset", or "switch to --preset".★ 124k GitHub starsSkillGoogle Agent ADK Guidegoogle/agents-cli · by googleThis skill should be used when the user wants to "write agent code", build an agent with ADK", "add a tool", "create a callback", "define an agent", use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).★ 6k GitHub starsSkillLive Visual EditorBuilderIO/skills · by BuilderIOOpen and collaboratively edit a running local app in Design, with shared fallback previews and source handoff. Use when the user asks to inspect, share, or edit a real local app in Design.★ 4.5k GitHub starsSkillClaude Mods TemplatesDannyMac180/skills · by DannyMac180Patterns, cost review and ready templates for Claude Mods (Claude Code plugins whose behaviour is a function-hooks module). Adds what the built-in mod authoring does not: proven designs (fork-check-draw, tool + ledger, mode registry, artifact-backed state), prompt-cache and token-cost review, a vetting pass for someone else's mod, and rules for mods that compose. USE WHEN: build a mod, make a claude mod, mod templates, quiz me after each turn, assumptions tool / register_assumption, supervisor that checks the turn, next-steps check, mode selector / mode registry, effort by domain, model router that keeps the cache, prompt cache cost of a mod, what does this mod cost per turn, review or vet someone's mod before installing, mods that work together, Kanban artifact as shared project state. NOT FOR: classic shell-command hooks in settings.json (PreToolUse etc.), a plain skill or slash command, MCP server authoring, or looking up the hooks API itself (use the engine's plugin-authoring guidance and generated types).★ 535 GitHub starsSkillHook Variant A/B GeneratorOotto-AI/claude-content-skills · by Ootto-AIGenerates two genuinely distinct hook variants for the same reel so you can post-test which opening actually wins. Use when the user says "give me two hooks to test", "A/B this hook", "which opening should I use", "hook variants".★ 139 GitHub starsSkillPhysics-Based UI Motiondiip3sh/feel · by diip3shBuild UI interactions whose motion comes from a physical model instead of durations and easing curves. Turn a feel described in words ("a toggle that feels heavy", "a drawer with a magnetic snap", "a card you throw into a corner", "a knob with heavy detents", "a sticky slider") into a production component driven by mass, stiffness, damping and force fields (magnets, friction, walls), on a line, in a plane or around a dial, plus a test rig that plots position, velocity and the force field, overlays the model's prediction on the measured motion, and exports the same spring to Framer Motion, react-spring, SwiftUI, Compose or CSS linear(). Use this whenever someone asks for an animation, transition, spring, gesture, drag, flick, snap points, bottom sheet, toggle, slider, carousel or any micro-interaction that should "feel" a certain way, or wants to tune or explain a spring, even if they never say "physics".★ 48 GitHub stars

More from CloudAI-X

SkillDatabase Schema & IndexingCloudAI-X/claude-workflow-v2 · by CloudAI-XDesigns database schemas, indexing strategies, query optimization, and migration patterns for SQL and NoSQL databases. Use when designing tables, optimizing queries, fixing N+1 problems, planning migrations, or when asked about database performance, normalization, ORMs, or data modeling.★ 1.4k GitHub starsAgentDebugging SpecialistCloudAI-X/claude-workflow-v2 · by CloudAI-XExpert debugging specialist for errors, test failures, crashes, segmentation faults, memory leaks, timeouts, race conditions, deadlocks, and unexpected behavior. Use PROACTIVELY when encountering any error, exception, or failing test. Performs systematic root cause analysis.★ 1.4k GitHub starsSkillAPI Design & DocumentationCloudAI-X/claude-workflow-v2 · by CloudAI-XDesigns REST and GraphQL APIs including endpoints, error handling, versioning, and documentation. Use when creating new APIs, designing endpoints, reviewing API contracts, or when asked about REST, GraphQL, or API patterns.★ 1.4k GitHub starsSkillTest Design & CoverageCloudAI-X/claude-workflow-v2 · by CloudAI-XDesigns and implements testing strategies for any codebase. Use when adding tests, improving coverage, setting up testing infrastructure, debugging test failures, or when asked about unit tests, integration tests, or E2E testing.★ 1.4k GitHub starsSkillInfrastructure as Code GuideCloudAI-X/claude-workflow-v2 · by CloudAI-XGuides Docker, CI/CD pipelines, deployment strategies, infrastructure as code, and observability setup. Use when writing Dockerfiles, configuring GitHub Actions, planning deployments, setting up monitoring, or when asked about containers, pipelines, Terraform, or production infrastructure.★ 1.4k GitHub starsAgentTechnical Documentation SpecialistCloudAI-X/claude-workflow-v2 · by CloudAI-XTechnical documentation specialist. Use for creating README files, API documentation, architecture docs, inline comments, user guides, changelogs, migration guides, release notes, FAQs, and troubleshooting docs. MUST BE USED when documentation is needed or when code changes require doc updates.★ 1.4k GitHub stars