mcpField
R
react-patterns

react-patterns

github.com/srbhrDevelopment29.2k83 installsUpdated 5d ago
Repository

About react-patterns

A Vercel-maintained performance guide for React and Next.js developers working on local or Dockerized deployments. It focuses on avoiding async waterfalls, reducing payloads, and keeping interfaces responsive without hosted or edge-specific optimizations.

Key features

  1. 01Avoid async waterfalls
  2. 02Stream UI with Suspense
  3. 03Reduce bundle and startup costs
  4. 04Trim RSC payloads
  5. 05Cache repeated server work
  6. 06Improve rendering responsiveness

Use cases

  1. 01Review React or Next.js code for regressions
  2. 02Speed up data-fetching routes
  3. 03Reduce hydration and memory overhead
  4. 04Keep long lists responsive

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/srbhr/resume-matcher --skill react-patterns

After installing, type/react-patternsin Claude Code to confirm it loaded.

Bundled filesREACT_PATTERNS.md

Details

From the project README

Vercel React Best Practices (Local/Docker)

Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. This version highlights the most important patterns for local installs or dockerized deployments.

Purpose

Provide a high-signal checklist to avoid async waterfalls, reduce client payloads, and keep UI responsive without relying on hosted or edge-specific optimizations.

When to Apply

  • Building or refactoring React components or Next.js pages
  • Implementing Server Actions, Route Handlers, or data fetching
  • Reducing startup time or memory footprint for local installs
  • Debugging sluggish UI or long hydration times
  • Reviewing code for performance regressions

Offline and Docker Focus

  • Optimize for cold-start and steady-state responsiveness over SEO.
  • Use in-process caches because the server process persists.
  • Avoid sequential awaits even for local APIs or databases.
  • Defer non-critical work until after render or after responses are sent.
  • Minimize RSC props to reduce hydration and memory overhead.

Top Findings

  • Eliminate async waterfalls by starting work early and awaiting late with Promise.all or better-all.
  • Use Suspense boundaries to stream UI instead of blocking the whole page on data.
  • Reduce initial load and memory via dynamic imports, conditional loading, and direct imports.
  • Minimize RSC payloads; pass only fields used and avoid duplicating serialized data.
  • Cache hot server work: React.cache per request and LRU for cross-request reuse.
  • Reduce client work with memoized subtrees, lazy state init, transitions, and content-visibility for large lists.

Core Patterns

  • async-parallel and async-api-routes to eliminate waterfalls
  • async-suspense-boundaries to stream slow sections
  • bundle-barrel-imports and bundle-dynamic-imports to reduce startup cost
  • server-serialization and server-dedup-props to shrink RSC payloads
  • server-cache-react and server-cache-lru to reuse hot work
  • rerender-lazy-state-init and rerender-transitions for responsive UI
  • rendering-content-visibility for long lists
  • client-swr-dedup for fetch deduplication

Outputs

  • REACT_PATTERNS.md for a condensed, offline-focused guide
  • AGENT.md for the full compiled reference

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Eliminating WaterfallsCRITICALasync-
2Bundle Size OptimizationCRITICALbundle-
3Server-Side PerformanceHIGHserver-
4Client-Side Data FetchingMEDIUM-HIGHclient-
5Re-render OptimizationMEDIUMrerender-
6Rendering PerformanceMEDIUMrendering-
7JavaScript PerformanceLOW-MEDIUMjs-
8Advanced PatternsLOWadvanced-

How to Use

Start with REACT_PATTERNS.md for the condensed guidance.

Full Compiled Document

For the complete guide with all rules expanded: AGENT.md

Comments

Markdown supported