react-best-practices

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

Updated Jul 31, 2026
One-click install
npx skills add https://github.com/AarnavBaddam/skills --skill react-best-practices-aarnavbaddam
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-best-practices
Source: https://github.com/AarnavBaddam/skills/tree/main/react-best-practices
Command: npx skills add https://github.com/AarnavBaddam/skills --skill react-best-practices-aarnavbaddam

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? React and Next.js codebases often suffer from performance issues like data-fetching waterfalls, bloated bundles, unnecessary re-renders, and inefficient server-side patterns. This Skill provides 64 prioritized, impact-rated rules from Vercel Engineering so AI agents and developers can consistently write, review, and refactor performant React/Next.js code. ## Core Features & Use Cases - 64 Prioritized Rules Across 8 Categories: Covers eliminating waterfalls, bundle size optimization, server-side performance, client-side data fetching, re-render optimization, rendering performance, JavaScript performance, and advanced patterns, each rated by impact from CRITICAL to LOW. - Incorrect vs. Correct Code Examples: Every rule includes concrete TypeScript/TSX examples showing the wrong pattern, the right pattern, and the reasoning behind it. - Use Case: When refactoring a Next.js page that fetches data sequentially, apply the async-parallel and server-parallel-fetching rules to convert sequential awaits into Promise.all() calls and component composition, cutting response times by 2-10x. ## Quick Start Ask the AI to review your React component or Next.js page against the Vercel React best practices rules and suggest performance improvements.

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?

Start independent async operations immediately and await them together with Promise.all(), or use the better-all library for partial dependency chains. In Server Components, restructure with component composition so sibling components fetch in parallel instead of sequentially.

How to reduce bundle size in a React or 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 non-critical third-party libraries until after hydration.

Does Next.js optimizePackageImports fix barrel file imports?

Yes, Next.js 13.5+ supports the experimental optimizePackageImports config option, which automatically transforms barrel imports into direct imports at build time. This lets you keep ergonomic imports while getting faster dev boot, builds, and cold starts.

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

React.cache() deduplicates fetches within a single request only, making it ideal for per-request queries like getCurrentUser. Use an LRU cache like lru-cache when data must persist across sequential requests, such as repeated user actions hitting multiple endpoints.

Why do Server Actions need their own authentication checks?

Server Actions are exposed as public endpoints just like API routes, so middleware or layout guards alone are insufficient. Always verify authentication and authorization inside each action, and validate inputs with a schema library like zod before performing mutations.

When should I avoid using Suspense boundaries for data fetching?

Avoid Suspense when data drives 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 streamed content replaces the fallback.