react-best-practices

Applies 57 prioritized React and Next.js performance optimization rules to eliminate waterfalls and reduce bundle size.

41|Updated Apr 14, 2026
One-click install
npx skills add https://github.com/DevayoshaUS/Women-scholarship --skill react-best-practices-devayoshaus
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: react-best-practices
Source: https://github.com/DevayoshaUS/Women-scholarship/tree/main/hackathon-main%20%281%29/hackathon-main/.agent/skills/nextjs-react-expert
Command: npx skills add https://github.com/DevayoshaUS/Women-scholarship --skill react-best-practices-devayoshaus

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? React and Next.js applications often suffer from slow page loads, large bundles, sequential data fetching waterfalls, and unnecessary re-renders that are hard to diagnose and fix systematically. ## Core Features & Use Cases - Waterfall Elimination: Parallelize independent async operations with Promise.all, better-all, and strategic Suspense boundaries to cut network latency. - Bundle Size Optimization: Avoid barrel file imports, apply dynamic imports with next/dynamic, and defer non-critical third-party libraries. - Server & Client Optimization: Authenticate Server Actions, minimize RSC serialization, use React.cache and LRU caching, deduplicate requests with SWR, and reduce re-renders with memoization patterns. - Use Case: When reviewing a slow Next.js page, follow the impact-prioritized checklist to find sequential awaits in API routes, replace barrel imports from libraries like lucide-react, and lazy-load heavy components like Monaco Editor. ## Quick Start Review my Next.js page component for performance issues and fix any data fetching waterfalls or bundle size problems.

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 instead of sequential awaits. For partial dependencies, use better-all or chain promises so dependent fetches start as early as possible.

How to reduce bundle size from barrel file imports?▼

Import directly from source files like 'lucide-react/dist/esm/icons/check' instead of the package entry point, which can load thousands of unused modules. In Next.js 13.5+, use the optimizePackageImports config option to transform barrel imports automatically.

Do Server Actions need authentication checks in Next.js?▼

Yes, Server Actions are exposed as public endpoints just like API routes. Always verify authentication and authorization inside each action rather than relying on middleware or layout guards, and validate inputs with a schema like zod.

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

React.cache deduplicates calls within a single request only, ideal for auth checks and database queries in one render pass. Use an LRU cache like lru-cache when data must persist across sequential requests, such as repeated user lookups.

Why does my React component re-render too often?▼

Common causes include subscribing to continuous values instead of derived booleans, missing functional setState updates causing stale closures, and unstable default props breaking memoization. Use useMemo for expensive computations and extract work into memoized child components.

When should I not use Suspense boundaries for data fetching?▼

Avoid Suspense when the 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 content loads.