react-best-practices

Applies 45 performance optimization rules to React and Next.js code.

Updated Aug 11, 2026
One-click install
npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill react-best-practices-duccuong159
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-best-practices
Source: https://github.com/DucCuong159/Realtime-chatapp/tree/main/.agent/skills/react-best-practices
Command: npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill react-best-practices-duccuong159

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 degrade user experience. This Skill provides a structured, impact-prioritized rule set so AI agents and developers can systematically identify and fix performance issues during code generation, review, and refactoring. ## Core Features & Use Cases - 45 Rules Across 8 Categories: Covers eliminating async 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: Every rule includes concrete TypeScript/TSX code comparisons with impact metrics (e.g., 2-10x improvement from parallelizing fetches, 200-800ms savings from avoiding barrel imports). - Priority-Driven Workflow: Rules are ranked from CRITICAL (waterfalls, bundle size) to LOW (advanced patterns) so refactoring effort targets the highest-impact fixes first. - Use Case: When writing a new Next.js page that fetches user data, config, and posts, apply the async rules to parallelize requests with Promise.all() and wrap slow sections in Suspense boundaries for faster initial paint. ## Quick Start Review my React component for performance issues and apply the relevant optimization rules from the react-best-practices guide.

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

Use Promise.all() for independent async operations, start promises early in API routes before awaiting them, and use better-all for operations with partial dependencies. These patterns convert sequential round trips into parallel execution for 2-10x improvement.

How to reduce bundle size in Next.js applications?

Import directly from source files instead of barrel files like lucide-react or @mui/material entry points, use next/dynamic for heavy components, and defer analytics libraries until after hydration. Next.js 13.5+ also offers optimizePackageImports for automatic transformation.

Does React.cache() work across multiple requests?

No, React.cache() only deduplicates within a single request. For cross-request caching of shared data, use an LRU cache like the lru-cache package, which is especially effective with Vercel Fluid Compute where function instances persist.

When should I not use Suspense boundaries in React?

Avoid Suspense for critical data needed for layout decisions, SEO-critical above-the-fold content, small fast queries where overhead is not worth it, and when you want to prevent layout shift between loading and loaded states.

Why does my React component re-render too often?

Common causes include subscribing to continuous values instead of derived booleans, using object dependencies in effects instead of primitives, and reading state at the top level when it is only used in callbacks. Narrow effect dependencies and subscribe to derived state to reduce re-renders.

What are the limitations of these React performance rules?

The rules target React and Next.js specifically and may not apply to other frameworks. If React Compiler is enabled, manual memoization with memo() and useMemo() is unnecessary since the compiler handles re-render optimization automatically.