Skip to content
Skills Library
Programming · Review & audit

react-performance

/react-performance

Impact-ordered performance rules for React and Next.js-style apps - async waterfalls, bundle size, server caching and server/client serialization, client fetch dedup, re-renders, rendering and hydration, JS hot paths. Use when writing or reviewing React code for speed, or diagnosing slow loads, slow interactions, large bundles or Core Web Vitals regressions.

Licence
MIT
Last repository change
12.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 12.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Impact-ordered performance rules for React and Next.js-style apps - async waterfalls, bundle size, server caching and server/client serialization, client fetch dedup, re-renders, rendering and hydration, JS hot paths. Use when writing or reviewing React code for speed, or diagnosing slow loads, slow interactions, large bundles or Core Web Vitals regressions.

Original author description

Impact-ordered performance rules for React and Next.js-style apps - async waterfalls, bundle size, server caching and server/client serialization, client fetch dedup, re-renders, rendering and hydration, JS hot paths. Use when writing or reviewing React code for speed, or diagnosing slow loads, slow interactions, large bundles or Core Web Vitals regressions.

How it works

  1. When to use
  2. Method
  3. 1. Eliminate waterfalls (critical)
  4. 2. Cut bundle size (critical)
  5. 3. Server-side (high)
  6. 4. Client data fetching (medium-high)
  7. 5. Re-renders (medium)
  8. 6. Rendering (medium)
  9. 7. JavaScript hot paths (low-medium)
  10. 8. Advanced (low)
Original SKILL.md headings · 127 lines, 1,309 words
SKILL.md preview
---
name: react-performance
description: Impact-ordered performance rules for React and Next.js-style apps - async waterfalls, bundle size, server caching and server/client serialization, client fetch dedup, re-renders, rendering and hydration, JS hot paths. Use when writing or reviewing React code for speed, or diagnosing slow loads, slow interactions, large bundles or Core Web Vitals regressions.
metadata:
  kind: skill
  castes: [coder, reviewer]
  tags: [react, nextjs, performance, web-vitals]
  version: 1
  status: vetted
  sources:
    - repo: affaan-m/ecc
      path: skills/react-performance/SKILL.md
      license: MIT
    - repo: vercel-labs/agent-skills
      path: skills/react-best-practices/ (SKILL.md, rules/*.md)
      license: MIT
---

# React Performance

Fix the expensive things first: network waterfalls and shipped JavaScript cost far more than an extra render. Work down the priority list and stop when the measured problem is gone. Code for every rule: [references/rules.md](references/rules.md).

## When to use

- Slow page loads, slow interactions, high client CPU, large bundles.
- A Core Web Vitals regression (LCP, INP, CLS).
- Reviewing data loading in Server Components, API routes or Server Actions.
- Reviewing re-render-heavy UI (live filters, large lists, frequent store updates).

Not here: component API design (`react-patterns`), framework-neutral loading strategy (`frontend-patterns`).

## Method

1. **Measure first.** Use the browser performance panel, the React DevTools profiler, a bundle analyzer, server timing logs or field Web Vitals. Write down the baseline.
2. **Name the metric and the cause** (for example "LCP 4.1s: three sequential awaits in the page").
3. **Apply the highest-priority rule that fits.** Do not micro-optimize while a waterfall or a large bundle remains.
4. **Measure again** and keep only the changes that helped.

| Metric | Look first at |
|---|---|
| LCP (load) | Waterfalls, bundle size, server time, resource hints, image priority |
| INP (interaction) | Re-renders, long tasks, heavy JS, transitions |
| CLS (layout shift) | Suspense fallbacks and images without reserved size, late-injected content |
| TBT / long tasks | Bundle size, third-party scripts, hydration cost |

## 1. Eliminate waterfalls (critical)

Every sequential `await` adds a full round trip.

- Check cheap synchronous conditions (props, flags in memory) before awaiting anything remote.
- Move each `await` into the branch that actually needs the value.
- Run independent work with `Promise.all`.
- Partial dependencies: start every promise as early as possible, await each only where its result is needed. Chain dependent calls with `.then` so they do not wait for unrelated ones.
- In API routes and Server Actions, start auth, config and data loads together.
- In Server Components, split sibling data needs into separate async child components so they fetch in parallel.
- Stream with `<Suspense>` near slow data; give fallbacks the content's size.

## 2. Cut bundle size (critical)

- Avoid barrel imports of large libraries (icon sets, component kits, utility libraries). Import the direct path, or use the framework's package-import optimization (for example Next.js `optimizePackageImports`). Check that deep paths ship types before using them.
- Keep dynamic `import()` paths statically analyzable: one literal path per branch, not template strings.
- Lazy-load heavy, below-the-fold or interaction-only components (`React.lazy` or the framework's dynamic import).
- Load features only when activated (admin panels, editors, charts).
- Load analytics, chat widgets and logging after hydration or on idle.
- Preload on intent: start the `import()` or data fetch on hover or focus.
- Check the result with a bundle analyzer.

## 3. Server-side (high)

- **Authenticate and authorize inside every Server Action.** It is a public endpoint whatever UI calls it.
- Deduplicate per request with `React.cache()` (one DB call however many components ask).
- Cache across requests with an LRU (process-local) or a shared cache, or the framework's data cache. Process-local caches do not help across isolated serverless instances.
- Pass the client only the fields it renders. Every prop crossing to a Client Component is serialized into the page.
- Serialization dedupes by reference: do not send both `items` and `items.toSorted()`. Transform on the client unless the transform is expensive.
- Hoist static I/O (fonts, logos, config) to module scope so it runs once.
- **Never keep request data in mutable module state.** Concurrent renders share the process and can leak one user's data into another's response.
- Run nested per-item fetches inside `Promise.all`, not a sequential loop.
- Defer non-blocking work (logging, analytics, cache warming) until after the response, for example Next.js `after()`.

## 4. Client data fetching (medium-high)

- Shared data goes through a server-state library (query or SWR style) so components share one request and one cache entry. Never `useEffect` + `fetch` for shared data.
- Share one global listener across component instances instead of one per instance.
- Mark scroll and touch listeners `{ passive: true }` when they do not call `preventDefault()`.
- `localStorage`: version the schema, keep payloads small (it is synchronous), and wrap access in try/catch.

## 5. Re-renders (medium)

If React Compiler is enabled, manual `memo`/`useMemo`/`useCallback` is mostly unnecessary. Keep only the structural rules here (derive state, subscribe narrowly, no inline components).

- Derive values during render; never mirror them into state with an effect.
- Do not subscribe to state that is only read inside a callback; read it when the callback runs.
- Subscribe to derived values (`cart.length > 0`), not whole objects.
- Memoize an expensive subtree as its own component so early returns skip it.
- Hoist default non-primitive props (`items ?? EMPTY`) so `memo` children are not broken by new identities.
- Use primitive effect dependencies, not freshly built objects.
- Use the functional `setState` form so callbacks need no state dependency.
- Use a lazy initializer for expensive initial state: `useState(() => parse(x))`.
- Do not `useMemo` trivial expressions.
- Split a hook with unrelated inputs into separate hooks.
- Put interaction logic in event handlers, not effects.
- Mark non-urgent updates with `startTransition`; use `useDeferredValue` to keep input responsive while an expensive view catches up.
- Keep fast-changing values that do not affect output (timers, last key) in refs.
- Never define components inside components.

## 6. Rendering (medium)

- Virtualize long lists, or use `content-visibility: auto` with `contain-intrinsic-size` for long static content.
- Animate a wrapper element's `transform`/`opacity`, not SVG attributes or layout properties.
- Hoist static JSX out of components.
- Round SVG path precision in exported assets.
- Client-only values needed before paint (theme): set them with a tiny inline script before hydration to avoid flicker.
- Use `suppressHydrationWarning` only on a single leaf that legitimately differs (timestamps), never on a subtree.
- Use `<Activity mode="hidden">` (React 19.2+) to hide and keep state of expensive toggled views instead of unmounting.
- Render conditionals with a ternary or explicit boolean; `count && <X/>` renders `0`.
- Use `useTransition`'s `isPending` for loading state instead of extra flags.
- Use React DOM resource hints (`preload`, `preconnect`, `prefetchDNS`) for critical resources.
- Put `defer` or `async` on non-critical scripts.

## 7. JavaScript hot paths (low-medium)

Only in measured hot paths: batch DOM style changes via classes; build a `Map` or `Set` for repeated lookups; combine `filter().map()` into one pass (`flatMap` or a loop); hoist `RegExp` creation out of loops; use a single loop for min/max instead of sorting; check lengths before expensive comparisons; return early; cache repeated storage reads; use `toSorted()` instead of mutating props; defer non-critical work to `requestIdleCallback`.

## 8. Advanced (low)

- `useEffectEvent` (React 19.2+) gives a stable function that sees the latest props. Never put it in a dependency list.
- Older React: store the latest handler in a ref updated inside an effect. Do not write refs during render.
- App-wide one-time initialization belongs in the entry module or behind a module-level guard, not in a component's mount effect (effects re-run on remount and run twice in development Strict Mode).

## Red flags in review

- Sequential independent `await`s; `await` before a cheap early return.
- `import { X } from 'huge-lib'` in client code without import optimization; template-string `import()`.
- Whole DB rows passed to Client Components; mutable module-level request state.
- Server Action without auth inside it.
- `useEffect` + `fetch`, effects that set derived state, components defined inside components.
- `{count && ...}`, unvirtualized lists of hundreds of rich rows, layout-shifting fallbacks.

## Done when

- The target metric has a before and after number, and the after meets the goal.
- No remaining higher-priority issue (waterfall, oversized bundle) on the measured path.
- Changes that did not move the metric were reverted.
Files in this package (2)
  • SKILL.md 9 KB
  • references/rules.md 9 KB

Versions

RepositoryScoreLicence
This page · Sanit-mann/The-Insectoids100MIT
HoangNguyen0403/agent-skills-standard100MIT
claude-dev-suite/claude-dev-suite100MIT
ssvinar/senior-agent-skills100MIT
krishna-modi12/frontend-design-pro100MIT
SHRIJANAGAIN/Nemo-Cli95Apache-2.0
ginaservice/ginaservice-skills95MIT
TheBushidoCollective/han95Apache-2.0
adilkalam/orca95MIT

Database snapshot: 13.11.2026 · package version 963bb248c110 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100react-best-practices
    React and Next.js performance rules: waterfalls, bundle size, server rendering, re-renders. Use when building or reviewing React components or optimizing a Next.js app.
  • 95nextjs15-performance
    Next.js 15 critical performance fixes. Use when writing React components, data fetching, Server Actions, or optimizing bundle size.
  • 100react-best-practices
    Run measurement-led React and Next.js performance audits for waterfalls, bundle size, RSC/server-client boundaries, hydration mismatch, rerender churn, script cost, and slow page interactions. Use when the user needs help diagnosing or refactoring a slow React UI, App Router…
  • 90react-best-practices
    React and Next.js performance rules from Vercel Engineering, ranked by impact, with local overrides for React Compiler and Next.js 16 caching. Use when writing or refactoring React components, reviewing a React or Next.js codebase for performance, fixing async data-fetching…
  • 100react-best-practices
    React and Next.js performance optimization guide from Vercel Engineering (70 rules in 8 categories). Use when writing, reviewing, or refactoring React/Next.js code to eliminate waterfalls, reduce bundle size, prevent re-renders, optimize Server Components, or fix performance…
  • 90perf-audit
    Audit performance — payload and bundle size, data-access patterns and waterfalls, caching, assets, and compute cost — reporting only issues with a measurable, user-visible cost. Use when asked about performance, slow loads, slow queries, slow renders, bundle size, memory use,…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.