react-best-practices

Applies 45 performance optimization rules when writing or refactoring React and Next.js code.

1|Updated Aug 17, 2025
One-click install
npx skills add https://github.com/ratnesh-maurya/mdconverter --skill react-best-practices-ratnesh-maurya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-best-practices
Source: https://github.com/ratnesh-maurya/mdconverter/tree/main/.claude/skills/react-best-practices
Command: npx skills add https://github.com/ratnesh-maurya/mdconverter --skill react-best-practices-ratnesh-maurya

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? React and Next.js applications often suffer from slow load times, data-fetching waterfalls, bloated bundles, and unnecessary re-renders. This Skill provides a prioritized, rule-based guide from Vercel Engineering so AI agents and developers consistently apply proven performance patterns when writing, reviewing, or refactoring code. ## Core Features & Use Cases - 45 Prioritized Rules Across 8 Categories: Covers eliminating waterfalls, bundle size optimization, server-side performance, client-side data fetching, re-render optimization, rendering performance, JavaScript micro-optimizations, and advanced patterns, each labeled with an impact level from CRITICAL to LOW. - Incorrect vs. Correct Code Examples: Every rule includes concrete TypeScript/TSX examples showing the anti-pattern and the optimized implementation, with impact metrics like "2-10x improvement" or "200-800ms import cost". - Use Case: When refactoring a Next.js page that sequentially awaits multiple fetches, apply the async rules to parallelize independent operations with Promise.all() and add strategic Suspense boundaries so the layout renders immediately while data streams in. ## Quick Start Review my Next.js page component using the react-best-practices skill and refactor any data-fetching waterfalls or bundle size issues you find.

Frequently Asked Questions about react-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I eliminate data fetching waterfalls in Next.js?

Execute independent async operations concurrently with Promise.all() instead of sequential awaits, and start promises early in API routes before awaiting them. For partial dependencies, use the better-all library to maximize parallelism automatically.

How to reduce bundle size in a React Next.js app?

Import directly from source files instead of barrel files like lucide-react or @mui/material entry points, which can load thousands of unused modules. Use next/dynamic for heavy components and defer analytics libraries until after hydration.

When should I use React.cache() versus an LRU cache?

React.cache() deduplicates fetches within a single request, ideal for authentication and database queries called multiple times per render. Use an LRU cache like lru-cache for data shared across sequential requests, such as repeated user lookups.

Does this guide work with React Compiler enabled?

Yes, but some manual optimizations become unnecessary. The guide notes that with React Compiler enabled, manual memoization with memo() and useMemo() and hoisting static JSX are handled automatically by the compiler.

When should I avoid using Suspense boundaries for data fetching?

Avoid Suspense when data is critical for layout decisions, when content is SEO-critical above the fold, or when queries are small and fast. The trade-off is faster initial paint versus potential layout shift when content loads.