vercel-react-best-practices

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

Updated Aug 5, 2024
One-click install
npx skills add https://github.com/SethyRung/movie-next --skill vercel-react-best-practices-sethyrung
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-react-best-practices
Source: https://github.com/SethyRung/movie-next/tree/main/.agents/skills/vercel-react-best-practices
Command: npx skills add https://github.com/SethyRung/movie-next --skill vercel-react-best-practices-sethyrung

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? React and Next.js codebases often suffer from slow load times, unnecessary re-renders, and data-fetching waterfalls that are hard to spot during development. This Skill provides a structured, prioritized rule set from Vercel Engineering so AI agents and developers can consistently apply proven performance patterns when writing, reviewing, or refactoring code. ## Core Features & Use Cases - 70 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. - Incorrect vs. Correct Examples: Each rule includes concrete code comparisons with impact metrics (e.g., 2-10x improvement from parallelizing fetches, 200-800ms savings from avoiding barrel imports). - Use Case: When refactoring a Next.js page that loads slowly, apply the waterfall rules to parallelize data fetching with Promise.all(), add Suspense boundaries for streaming, and replace barrel imports with direct imports to cut bundle size. ## 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 vercel-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() instead of awaiting sequentially. For partial dependencies, use better-all or chain promises so dependent fetches start as early as possible, yielding 2-10x improvements.

How to reduce React bundle size from barrel file imports?

Import directly from source files instead of barrel entry points, or use Next.js optimizePackageImports to transform imports automatically. Barrel files in libraries like lucide-react or MUI can load thousands of unused modules, costing 200-800ms per cold start.

When should I use Suspense boundaries in React Server Components?

Use Suspense when only part of a page needs async data, so the wrapper layout renders immediately while data streams in. Avoid it for SEO-critical above-the-fold content or when layout shift from loading states would hurt the user experience.

Does this skill work with React versions that have useEffectEvent?

Yes, several advanced rules cover useEffectEvent for stable callback refs and explain not to include Effect Events in dependency arrays. Fallback patterns using refs are also provided for older React versions.

Why should Server Actions be authenticated like API routes?

Server Actions are exposed as public endpoints and can be invoked directly, bypassing middleware or layout guards. Always verify authentication and authorization inside each action, and validate inputs with a schema like Zod before performing mutations.

What are the limitations of these React performance rules?

Some rules involve trade-offs, such as Suspense boundaries causing layout shift or memoization adding overhead for cheap computations. Each rule documents when not to apply it, so judgment is still required for context-specific decisions.