MR
Mayur Rathi
@mayurrathi
⭐ 40.7k GitHub stars

React Best Practices

React Best Practices is an code AI skill with a core value of React and Next. It helps developers solve real-world problems in the code domain, boosting efficiency, automating repetitive tasks, and optimizing workflows.

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

Last verified on: 2026-07-07

Quick Facts

Category code
Works With Claude
Source sickn33/antigravity-awesome-skills
Stars ⭐ 40.7k
Last Verified 2026-07-07
Risk Level Low
mkdir -p ./skills/react-best-practices && curl -sfL https://raw.githubusercontent.com/sickn33/antigravity-awesome-skills/main/skills/react-best-practices/SKILL.md -o ./skills/react-best-practices/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# 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


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

🎯 Best For

  • Engineering teams doing code reviews
  • Open source maintainers
  • Tech leads planning refactors
  • Developers modernizing legacy code
  • UI designers

💡 Use Cases

  • Reviewing pull requests for security vulnerabilities
  • Checking code style consistency
  • Migrating from class components to hooks
  • Breaking apart monolithic functions

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply React Best Practices to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Does this skill check for OWASP Top 10?

Security-focused review skills often include OWASP checks. Check the skill content for specific vulnerability categories covered.

Does this handle breaking changes?

Refactoring skills identify breaking changes but always run your test suite after applying suggestions.

Does this work with Figma?

Some design skills integrate with Figma plugins. Check the Works With section for supported tools.

Is React Best Practices compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for React Best Practices?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

⚠️ Common Mistakes to Avoid

Blindly accepting AI suggestions

Always verify AI-generated review comments. Some suggestions may not apply to your specific codebase conventions.

Refactoring without tests

Never refactor critical paths without a comprehensive test suite to catch regressions.

Skipping usability testing

AI-generated designs should be validated with real users before development.

Skipping validation

Always test AI-generated code changes, even for simple refactors.

🔗 Related Skills