react-best-practices

Reviews React and Next.js code against 64 performance optimization rules across eight categories.

Updated Aug 21, 2025
One-click install
npx skills add https://github.com/Adithiya-S/AI-Study-Companion --skill react-best-practices-adithiya-s
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-best-practices
Source: https://github.com/Adithiya-S/AI-Study-Companion/tree/main/.agents/skills/react-best-practices
Command: npx skills add https://github.com/Adithiya-S/AI-Study-Companion --skill react-best-practices-adithiya-s

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? React and Next.js codebases often suffer from hidden performance issues like async waterfalls, bloated bundles, and unnecessary re-renders that are hard to catch during manual code review. ## Core Features & Use Cases - Rule-Based Review: Applies 64 prioritized rules across 8 categories, from eliminating waterfalls (CRITICAL) to advanced patterns (LOW), each with incorrect vs. correct code examples. - Automatic Triggering: Activates on TSX/JSX component files and React imports, with validation warnings for legacy CSS-in-JS libraries like styled-components, Emotion, MUI, and Chakra. - Migration Guidance: Detects legacy styling approaches and chains to shadcn/ui + Tailwind recommendations for modern Vercel-native UI. - Use Case: After editing several components in src/components, run a review to catch sequential awaits in data fetching, barrel file imports inflating the bundle, and missing memoization in hot render paths. ## Quick Start Review my React components in src/components for performance issues using the react best practices checklist.

Frequently Asked Questions about react-best-practices

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

FAQPage Schema
How do I fix async waterfalls in React and Next.js?

Start independent promises immediately and await them together with Promise.all, or use better-all for partial dependency chains. In API routes, kick off auth and config fetches before awaiting, and use Suspense boundaries so layout renders while data streams in.

How to reduce React bundle size from barrel file imports?

Import directly from source files instead of barrel entry points, since libraries like lucide-react or MUI can load thousands of unused modules. In Next.js 13.5+, enable optimizePackageImports to transform barrel imports automatically at build time.

What is the best way to prevent unnecessary React re-renders?

Derive state during rendering instead of effects, use functional setState updates, narrow effect dependencies to primitives, and extract expensive work into memoized components. Use useDeferredValue or startTransition for non-urgent updates to keep inputs responsive.

Should I migrate from styled-components or MUI to shadcn/ui?

The skill flags styled-components, Emotion, MUI, and Chakra as legacy CSS-in-JS and recommends shadcn/ui with Tailwind for better SSR performance and Vercel ecosystem alignment. The warning is skipped if your project already uses shadcn or Tailwind.

When should I not use 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 enough that the overhead is not worth it. It trades faster initial paint for potential layout shift.