vercel-react-best-practices

Optimize React and Next.js performance by eliminating waterfalls and reducing bundle size.

Updated Feb 27, 2024
One-click install
npx skills add https://github.com/MaxStrootmann/lumen-yoga --skill vercel-react-best-practices-maxstrootmann
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-react-best-practices
Source: https://github.com/MaxStrootmann/lumen-yoga/tree/main/.agents/skills/vercel-react-best-practices
Command: npx skills add https://github.com/MaxStrootmann/lumen-yoga --skill vercel-react-best-practices-maxstrootmann

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide reduces performance regressions and runtime inefficiencies in React and Next.js projects by providing prescriptive, prioritized rules that engineers and agents can apply to writing, reviewing, and refactoring code to improve load times, time-to-interactive, and server responsiveness.

Core Features & Use Cases

  • Eliminating Waterfalls: patterns to defer awaits, parallelize dependent tasks, and structure components to avoid sequential server-side fetches.
  • Bundle Size & Loading: guidance on avoiding barrel imports, using dynamic imports and preloading, and deferring non-critical third-party libraries.
  • Server & Client Data Patterns: recommendations for per-request deduplication, cross-request LRU caching, minimizing RSC serialization, authenticating server actions, and scheduling non-blocking work.
  • Use Case: Audit a Next.js application to produce targeted refactors such as splitting heavy components, hoisting static JSX, consolidating fetches, and reducing serialized props for faster pages.

Quick Start

Audit my Next.js page and return prioritized, actionable performance fixes with code examples.

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 optimize React and Next.js performance and reduce bundle size?

To optimize React and Next.js performance, you must eliminate fetch waterfalls, minimize server-client serialization, and use dynamic imports. This reduces bundle size and improves load times and server responsiveness.

What is the best way to prevent server-side data fetching waterfalls in Next.js?

Preventing server-side data fetching waterfalls requires deferring sequential awaits and parallelizing dependent fetches. Restructuring React components to avoid sequential server-side fetches eliminates these bottlenecks.

How do I reduce server-client serialization in React Server Components?

Minimizing RSC serialization involves reducing serialized props passed between server and client components. You should hoist static JSX, split heavy client components, and consolidate fetches to reduce serialized data.

Can I use dynamic imports and preloading to improve Next.js load times?

Yes, you can use dynamic imports and preloading to improve Next.js load times. Avoid barrel imports, defer non-critical third-party libraries, and split heavy components to minimize the initial bundle size.

Does this approach work for caching and non-blocking server patterns in Next.js?

Yes, this approach supports caching and non-blocking server patterns in Next.js. It provides guidance on per-request deduplication, cross-request LRU caching, authenticating server actions, and scheduling non-blocking work.

What are the limitations when auditing a Next.js application for performance regressions?

When auditing a Next.js application for performance regressions, limitations arise if heavy client components cannot be split or if server-client serialized props cannot be consolidated. Targeted refactors require compatible build configurations.