AgentSkillsCN

react-best-practices

React 与 Next.js 应用程序的性能优化规则。

SKILL.md
--- frontmatter
name: react-best-practices
description: Performance optimization rules for React and Next.js applications
version: 1.0.0
author: vercel
source: https://github.com/vercel-labs/agent-skills/tree/main/skills/react-best-practices

React Best Practices

This skill provides 57 performance optimization rules for React and Next.js applications, organized by impact level. Apply these rules when writing components, implementing data fetching, reviewing code, or optimizing bundle sizes.

Rule Categories by Impact

PriorityCategoryPrimary Benefit
CRITICALEliminating Waterfalls2-10× speedup via parallelization
CRITICALBundle SizeFaster cold starts, reduced TTI
HIGHServer-Side PerformanceEliminates sequential fetching
MEDIUM-HIGHClient Data FetchingAutomatic request deduplication
MEDIUMRe-render OptimizationPrevents wasted computations
MEDIUMRendering PerformanceBrowser optimization
LOW-MEDIUMJavaScript PerformanceAlgorithm efficiency
LOWAdvanced PatternsEdge case patterns

Quick Reference

Most Impactful Rules

  1. Defer await until needed - Don't await at function start
  2. Avoid barrel imports - Import directly from source files
  3. Use Promise.all() - Parallelize independent operations
  4. Dynamic imports - Lazy-load heavy components
  5. Use React.cache() - Deduplicate per-request data

See rules.md for the complete 57-rule reference with code examples.

When to Apply

  • Writing new React/Next.js components
  • Reviewing code for performance issues
  • Refactoring existing codebases
  • Optimizing bundle size and load times
  • Implementing data fetching patterns