Skip to content
SkillImported

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, bundle optimization, or performance improvements.

Imported description, not reviewed yet

This item came from its original repository and was only scanned automatically; no editor has written an Arabic description for it yet. Read its content yourself before you rely on it. This page is not indexed by search engines until it is reviewed.

Download

Files: 51 · Size: 129 KB

Download the ZIP

The file carries the license of the original source.

Install

After downloading, run the command in a terminal. unzip asks before it replaces any file that is there.

  • For this project

    It goes in: .claude/skills/react-best-practices/

    mkdir -p .claude/skills && unzip ~/Downloads/react-best-practices.zip -d .claude/skills

  • For your account on the whole machine

    It goes in: ~/.claude/skills/react-best-practices/

    mkdir -p ~/.claude/skills && unzip ~/Downloads/react-best-practices.zip -d ~/.claude/skills

Instructions

Vercel React Best Practices

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

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

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

Files

  • folderrules60 KB
    • _sections.md1.5 KB
    • _template.md631 B
    • advanced-event-handler-refs.md1.4 KB
    • advanced-use-latest.md1.2 KB
    • async-api-routes.md1.1 KB
    • async-defer-await.md2 KB
    • async-dependencies.md942 B
    • async-parallel.md654 B
    • async-suspense-boundaries.md2.5 KB
    • bundle-barrel-imports.md2.3 KB
    • bundle-conditional.md866 B
    • bundle-defer-third-party.md920 B
    • bundle-dynamic-imports.md791 B
    • bundle-preload.md1.1 KB
    • client-event-listeners.md1.9 KB
    • client-swr-dedup.md1.1 KB
    • js-batch-dom-css.md1.9 KB
    • js-cache-function-results.md1.9 KB
    • js-cache-property-access.md532 B
    • js-cache-storage.md1.6 KB
    • js-combine-iterations.md753 B
    • js-early-exit.md1.1 KB
    • js-hoist-regexp.md1 KB
    • js-index-maps.md837 B
    • js-length-check-first.md1.7 KB
    • js-min-max-loop.md2.1 KB
    • js-set-map-lookups.md532 B
    • js-tosorted-immutable.md1.7 KB
    • rendering-activity.md564 B
    • rendering-animate-svg-wrapper.md1.2 KB
    • rendering-conditional-render.md980 B
    • rendering-content-visibility.md815 B
    • rendering-hoist-jsx.md1 KB
    • rendering-hydration-no-flicker.md2.3 KB
    • rendering-svg-precision.md588 B
    • rerender-defer-reads.md973 B
    • rerender-dependencies.md824 B
    • rerender-derived-state.md724 B
    • rerender-functional-setstate.md2.9 KB
    • rerender-lazy-state-init.md2 KB
    • rerender-memo.md1.1 KB
    • rerender-transitions.md1 KB
    • server-after-nonblocking.md2 KB
    • server-cache-lru.md1.3 KB
    • server-cache-react.md681 B
    • server-parallel-fetching.md1.5 KB
    • server-serialization.md996 B
  • AGENTS.md59 KB
  • LICENSE1 KB
  • README.md3.3 KB
  • SKILL.md5.1 KB
  • metadata.json921 B

Comments (0)

No comments yet. Be the first.

Sign in to comment. Commenting comes at level 1 (Member).

Report

Similar items

  • SkillImported

    3d-web-experience

    Expert in building 3D experiences for the web - Three.js, React Three Fiber, Spline, WebGL, and interactive 3D scenes. Covers product configurators, 3D portfolios, immersive websites, and bringing depth to web experiences. Use when: 3D webs

    MITFiles: 1

  • SkillImported

    accessibility

    Audit and improve web accessibility following WCAG 2.1 guidelines. Use when asked to "improve accessibility", "a11y audit", "WCAG compliance", "screen reader support", "keyboard navigation", or "make accessible".

    MITFiles: 2

  • SkillImported

    accessibility-auditor

    Web accessibility specialist for WCAG compliance, ARIA implementation, and inclusive design. Use when auditing websites for accessibility issues, implementing WCAG 2.1 AA/AAA standards, testing with screen readers, or ensuring ADA complianc

    MITFiles: 1

  • SkillImported

    accessibility-compliance

    Implement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive

    MITFiles: 5

  • SkillImported

    algolia-search

    Expert patterns for Algolia search implementation, indexing strategies, React InstantSearch, and relevance tuning Use when: adding search to, algolia, instantsearch, search api, search functionality.

    MITFiles: 1

  • SkillImported

    angular

    Modern Angular (v20+) expert with deep knowledge of Signals, Standalone Components, Zoneless applications, SSR/Hydration, and reactive patterns.

    MITFiles: 3