react-best-practices
/react-best-practices
Vercel Engineering's 70 rules, ordered by impact across 8 categories. TRIGGER WHEN: writing, reviewing, or refactoring React or Next.js code: components, pages, data fetching, bundle size, or render performance.
- Author
- acaprino ↗
- Repository
- alfio-claude-plugins ↗
- Licence
- MIT
- Last repository change
- 27.10.2026
Assessment and security
- Files in this package
- 77
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Vercel Engineering's 70 rules, ordered by impact across 8 categories. TRIGGER WHEN: writing, reviewing, or refactoring React or Next.js code: components, pages, data fetching, bundle size, or render performance.
Original author description
Vercel Engineering's 70 rules, ordered by impact across 8 categories. TRIGGER WHEN: writing, reviewing, or refactoring React or Next.js code: components, pages, data fetching, bundle size, or render performance.
How it works
- When to Apply
- Rule Categories by Priority
- Quick Reference
- How to Use
SKILL.md preview
--- name: react-best-practices description: > Vercel Engineering's 70 rules, ordered by impact across 8 categories. TRIGGER WHEN: writing, reviewing, or refactoring React or Next.js code: components, pages, data fetching, bundle size, or render performance. --- <daodan_host_binding host="opencode"> This binding governs execution of this package and its loaded references. It takes precedence over executable examples written for another host. Use only registered tools and their actual input schema; an example never creates a tool, argument, permission, model alias or nested worker capability. Preserve the generated worker allowlist, dependency closure, scope and delivery contracts. OpenCode V2 binding: repository reads use read/glob/grep, writes use write/edit/patch, shell execution uses shell, network tools are webfetch/websearch, and clarification uses the registered question tool. shell takes command, optional workdir, timeout in milliseconds and background. It does not provide interactive stdin. Persistent capture uses background: true and an explicit noninteractive stop signal. Load skills with skill using id: "<plugin>:<skill>". Dispatch registered roles with subagent using agent: "<owner>:<role>", description and prompt; optional sessionID continues that child, and background: true requests asynchronous completion. Use only roles allowed by the current harness and permissions. A child cannot dispatch nested workers when its permissions or the configured depth deny it. Workflow entries are /<plugin>:<workflow>, registered by the package loader. Inherit the session model; an override requires its authorized, actually available provider/model identity, not another host's short model alias. The loader includes required local providers and registers plugin-declared MCP servers. Qualified foreign providers need a compatible V2 plugin/skill provisioned through this host, never a Claude marketplace command. Check the active registry: registration metadata alone does not prove a connected server or usable tool. Inherit the active session's model and default variant. A source model alias such as sonnet is not a portable override; request a different model only through an explicit adapter mapping to a valid host identity and user authorization. The executing agent and its coordinator own continuation, recovery, verification and delivery. Skills supply knowledge and method instructions; they are not executors or a runtime persistence mechanism. Resolve each component by kind and exact installed identity. A role is dispatched as a worker, a skill loads instructions, and a workflow starts its declared method. Kernel owner-qualified skill references are logical provider identities: resolve them to the actual host registry name and verified installed provider path. Do not invent a registry string by adding an owner's prefix when the host does not use it. Do not load an agent identity as a skill or execute a workflow name as a shell command. Declared required foreign providers remain mandatory. If a required provider or capability (including required MCP access or isolation) is unavailable, stop its dependent phase and report the missing capability. Optional external providers follow the method's declared selection and absence behavior; their absence alone does not block the base workflow. Report any explicitly requested but unavailable provider contribution as unfulfilled and continue independent work. Do not install a different host's plugin or substitute unrelated skills to claim coverage. Shell execution alone does not establish interactive stdin. Before a capture or checkpoint, use an available session-control mechanism. When stdin is unavailable, keep user-driven capture in a supported background process with bounded output and an explicit stop signal controlled by the coordinator after the user's completion message. Close owned browser/process resources on completion or cancellation. Continue working within the current authorization while the requested result is achievable. After a tool error, inspect its cause, correct the relevant input or implementation, retry when justified and verify the outcome; never repeat a failing action blindly. Do not close the turn with a promise or a partial result when an authorized next step can still produce or verify the requested result. Stop only for a documented real impediment, a missing required capability, an unresolved human decision or the caller's stop request. At that boundary, report completed results, remaining work and the concrete prerequisite for continuation; continue any independent work that the blocker does not prevent. A tool's successful exit, a worker stop or an idle session is not the deliverable. Return final text naming observed findings, artifact paths, executed checks and blockers. An empty worker result is missing delivery: inspect or resume that worker when permitted, or record failure. Verify required artifacts and candidate gates before marking the requested outcome complete. This is an execution binding, not a rewrite of source examples. Preserve programming language fences, domain code and host APIs that are the subject of marketplace-ops or agent-sdk-builder. A host-as-subject API is not a tool provided to this session. Compiled binding and static checks do not prove an installed host executed a run. </daodan_host_binding> # 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 values - `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-analyzable-paths` - Prefer statically analyzable import and file-system paths to avoid broad bundles and traces - `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-auth-actions` - Authenticate server actions like API routes - `server-cache-react` - Use React.cache() for per-request deduplication - `server-cache-lru` - Use LRU cache for cross-request caching - `server-dedup-props` - Avoid duplicate serialization in RSC props - `server-hoist-static-io` - Hoist static I/O (fonts, logos) to module level - `server-no-shared-module-state` - Avoid module-level mutable request state in RSC/SSR - `server-serialization` - Minimize data passed to client components - `server-parallel-fetching` - Restructure components to parallelize fetches - `server-parallel-nested-fetching` - Chain nested fetches per item in Promise.all - `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 - `client-passive-event-listeners` - Use passive listeners for scroll - `client-localstorage-schema` - Version and minimize localStorage data ### 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-memo-with-default-value` - Hoist default non-primitive props - `rerender-dependencies` - Use primitive dependencies in effects - `rerender-derived-state` - Subscribe to derived booleans, not raw values - `rerender-derived-state-no-effect` - Derive state during render, not effects - `rerender-functional-setstate` - Use functional setState for stable callbacks - `rerender-lazy-state-init` - Pass function to useState for expensive values - `rerender-simple-expression-in-memo` - Avoid memo for simple primitives - `rerender-split-combined-hooks` - Split hooks with independent dependencies - `rerender-move-effect-to-event` - Put interaction logic in event handlers - `rerender-transitions` - Use startTransition for non-urgent updates - `rerender-use-deferred-value` - Defer expensive renders to keep input responsive - `rerender-use-ref-transient-values` - Use refs for transient frequent values - `rerender-no-inline-components` - Don't define components inside components ### 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-hydration-suppress-warning` - Suppress expected mismatches - `rendering-activity` - Use Activity component for show/hide - `rendering-conditional-render` - Use ternary, not && for conditionals - `rendering-usetransition-loading` - Prefer useTransition for loading state - `rendering-resource-hints` - Use React DOM resource hints for preloading - `rendering-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 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 - `js-flatmap-filter` - Use flatMap to map and filter in one pass - `js-request-idle-callback` - Defer non-critical work to browser idle time ### 8. Advanced Patterns (LOW) - `advanced-effect-event-deps` - Don't put `useEffectEvent` results in effect deps - `advanced-event-handler-refs` - Store event handlers in refs - `advanced-init-once` - Initialize app once per app load - `advanced-use-latest` - useLatest for stable callback refs ## How to Use - Read `references/react19-stores-and-effects.md` for React 19 Compiler limits, external store selector fixes (`useShallow`, `createSelector`, `subscribeWithSelector`, Jotai `atomFamily`), `useEffect`/`useCallback` loop and stale-closure fixes, teardown patterns, and TanStack Query/Virtual configurations. - Read individual rule files in the `rules/` directory for detailed explanations and code examples. Each rule file contains: - Brief explanation of why it matters - Incorrect code example with explanation - Correct code example with explanation - Additional context and references - The `references.md` file contains all 70 rules expanded into a single compiled document. - Read `references/audit.md` when running the React performance audit as a procedure (the React stack audit of `/daodan:check-health`): scope detection, ESLint ground truth, the isolated `react-performance-optimizer` review and the scored report under the run directory.
Files in this package (77)
- SKILL.md 12 KB
- SKILL.toml 1 KB
- references.md 111 KB
- references/audit.md 11 KB
- references/react19-stores-and-effects.md 11 KB
- rules/_sections.md 7 KB
- rules/_template.md 6 KB
- rules/advanced-effect-event-deps.md 7 KB
- rules/advanced-event-handler-refs.md 7 KB
- rules/advanced-init-once.md 6 KB
- rules/advanced-use-latest.md 6 KB
- rules/async-api-routes.md 6 KB
- rules/async-cheap-condition-before-await.md 6 KB
- rules/async-defer-await.md 7 KB
- rules/async-dependencies.md 6 KB
- rules/async-parallel.md 6 KB
- rules/async-suspense-boundaries.md 7 KB
- rules/bundle-analyzable-paths.md 7 KB
- rules/bundle-barrel-imports.md 8 KB
- rules/bundle-conditional.md 6 KB
- rules/bundle-defer-third-party.md 6 KB
- rules/bundle-dynamic-imports.md 6 KB
- rules/bundle-preload.md 6 KB
- rules/client-event-listeners.md 7 KB
- rules/client-localstorage-schema.md 7 KB
- rules/client-passive-event-listeners.md 7 KB
- rules/client-swr-dedup.md 6 KB
- rules/js-batch-dom-css.md 8 KB
- rules/js-cache-function-results.md 7 KB
- rules/js-cache-property-access.md 6 KB
- rules/js-cache-storage.md 7 KB
- rules/js-combine-iterations.md 6 KB
- rules/js-early-exit.md 6 KB
- rules/js-flatmap-filter.md 6 KB
- rules/js-hoist-regexp.md 6 KB
- rules/js-index-maps.md 6 KB
- rules/js-length-check-first.md 7 KB
- rules/js-min-max-loop.md 7 KB
- rules/js-request-idle-callback.md 8 KB
- rules/js-set-map-lookups.md 6 KB
- rules/js-tosorted-immutable.md 7 KB
- rules/rendering-activity.md 6 KB
- rules/rendering-animate-svg-wrapper.md 6 KB
- rules/rendering-conditional-render.md 6 KB
- rules/rendering-content-visibility.md 6 KB
- rules/rendering-hoist-jsx.md 6 KB
- rules/rendering-hydration-no-flicker.md 7 KB
- rules/rendering-hydration-suppress-warning.md 6 KB
- rules/rendering-resource-hints.md 8 KB
- rules/rendering-script-defer-async.md 7 KB
- rules/rendering-svg-precision.md 6 KB
- rules/rendering-usetransition-loading.md 7 KB
- rules/rerender-defer-reads.md 6 KB
- rules/rerender-dependencies.md 6 KB
- rules/rerender-derived-state-no-effect.md 6 KB
- rules/rerender-derived-state.md 6 KB
- rules/rerender-functional-setstate.md 8 KB
- rules/rerender-lazy-state-init.md 7 KB
- rules/rerender-memo-with-default-value.md 6 KB
- rules/rerender-memo.md 6 KB
- rules/rerender-move-effect-to-event.md 6 KB
- rules/rerender-no-inline-components.md 7 KB
- rules/rerender-simple-expression-in-memo.md 6 KB
- rules/rerender-split-combined-hooks.md 7 KB
- rules/rerender-transitions.md 6 KB
- rules/rerender-use-deferred-value.md 7 KB
- rules/rerender-use-ref-transient-values.md 7 KB
- rules/server-after-nonblocking.md 7 KB
- rules/server-auth-actions.md 8 KB
- rules/server-cache-lru.md 6 KB
- rules/server-cache-react.md 7 KB
- rules/server-dedup-props.md 7 KB
- rules/server-hoist-static-io.md 9 KB
- rules/server-no-shared-module-state.md 7 KB
- rules/server-parallel-fetching.md 7 KB
- rules/server-parallel-nested-fetching.md 6 KB
- rules/server-serialization.md 6 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · acaprino/alfio-claude-plugins | 100 | MIT |
| acaprino/alfio-claude-plugins | 100 | MIT |
| acaprino/alfio-claude-plugins | 100 | MIT |
| acaprino/alfio-claude-plugins | 100 | MIT |
| acaprino/alfio-claude-plugins | 100 | MIT |
| akillness/jeo-skills | 100 | MIT |
| kamiazya/whiteboard | 100 | Apache-2.0 |
| acaprino/alfio-claude-plugins | 100 | MIT |
| mastra-ai/mastra | 100 | Apache-2.0 |
Identical content appears in 1 other GitHub folders. We show one copy with the highest score.
Database snapshot: 13.11.2026 · package version fbbaaca64144 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100vercel-react-best-practices
Use when writing, reviewing or refactoring React/Next.js code for performance: rendering, data fetching, bundle size. - 100vercel-react-best-practices
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,… - 90vercel-react-best-practices
React and Next.js performance optimization guidelines from Vercel Engineering. Use when writing, reviewing, or refactoring React/Next.js code involving components, Next.js pages, Server Components, Server Actions, data fetching, bundle size, rendering behavior, or performance improvements. - 100vercel-react-best-practices
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,… - 100vercel-react-best-practices
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,… - 95vercel-react-best-practices
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,…