Part 4 showed how React decides what to render and when: render and commit, priorities, transitions. That model tells you why an app can feel slow. It doesn't tell you which part of your app is slow. For that you need numbers.
This chapter is about getting them. Every performance fix in the next three chapters (memoization, the React Compiler, virtualization, code splitting) has a cost in complexity. You pay that cost only where a measurement says it buys something. So before any of them, you learn the tools: React's <Profiler>, the React DevTools Profiler, React's Performance tracks in Chrome, the browser's Performance panel, and the Core Web Vitals that tell you whether real users are suffering.
The problem: it's slow, but where?#
Here's the reading list from Part 4, with a search box, the filtered list and a small stats panel. Type a few letters quickly. The input stutters.
import { useState } from "react";
import { books } from "guide-tools";
import { Stats } from "./Stats";
export default function App() {
const [query, setQuery] = useState("");
const visible = books.filter((b) =>
b.title.toLowerCase().includes(query.toLowerCase())
);
return (
<div>
<input
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="Search books"
/>
<ul>
{visible.map((b) => (
<li key={b.id}>{b.title}</li>
))}
</ul>
<Stats />
</div>
);
}Here the culprit is in a file called Stats.tsx with a slowDown(60) in it, so you know where to look. In a real app you don't. The usual guesses are "the list is too long", "filtering is expensive" or "we need useMemo". Here the list has ten items and filtering takes microseconds. The 60 ms goes to a component that doesn't even use the query. It re-renders because its parent did, as chapter 23 explained.
Guessing would have sent you to the wrong component. So the first rule of React performance is the one in this chapter's title: measure first. Find the slow thing, fix that one thing, measure again.
Build a stopwatch#
Before reaching for tools, it's worth building the crudest possible measurement, because it shows what any React profiler has to deal with.
A component's body runs during the render phase. Its layout effects run during the commit, after the DOM is updated and after its children's layout effects. So if you note the time at the top of a component and read it again in useLayoutEffect, you've timed everything from the moment that component started rendering until its layout effect ran: its own subtree, but also everything React rendered after it in the same pass, plus part of the commit.
import { useLayoutEffect, useState } from "react";
import { books, slowDown } from "guide-tools";
function useStopwatch(name: string) {
const start = performance.now();
useLayoutEffect(() => {
console.log(`${name}: ${(performance.now() - start).toFixed(1)} ms`);
});
}
function BookList({ query }: { query: string }) {
useStopwatch("BookList");
const visible = books.filter((b) =>
b.title.toLowerCase().includes(query.toLowerCase())
);
return <ul>{visible.map((b) => <li key={b.id}>{b.title}</li>)}</ul>;
}
function Stats() {
useStopwatch("Stats");
slowDown(60);
return <p>{books.length} books</p>;
}
export default function App() {
useStopwatch("App");
const [query, setQuery] = useState("");
return (
<div>
<input value={query} onChange={(e) => setQuery(e.target.value)} placeholder="Type here" />
<BookList query={query} />
<Stats />
</div>
);
}Type a letter and read the console. All three report about 60 ms, including BookList, which does almost nothing. React renders the whole tree before it commits anything, so BookList's clock keeps running while its sibling Stats renders, and no layout effect fires until the entire render pass is done. App's number includes Stats for the same reason. You learn that something under App costs 60 ms, and nothing about which component it is.
That's the core problem any React profiler has to solve: render work is interleaved across the tree and committed in one batch, so wall-clock time between "I started" and "I committed" doesn't belong to any one component. The homemade version has other problems too. It can't separate a component's own time from its children's. It only fires when the component renders, so a skipped component is invisible. It adds code to every component you want to measure. And it runs in development mode, which does extra work. React's built-in tools fix the attribution problem and the first three of these. The last one you fix by measuring the right build, covered below.
The real thing, in code: <Profiler>#
You met <Profiler> in chapter 22. Here's the recap, with measurement in mind: it does what the stopwatch tried to do, properly. Wrap any subtree in <Profiler id="..." onRender={fn}>, and React calls fn every time something inside that subtree commits:
function onRender(
id: string, // the id prop of this Profiler
phase: "mount" | "update" | "nested-update",
actualDuration: number, // ms spent rendering this subtree for this update
baseDuration: number, // estimated ms to re-render the whole subtree with no memoization
startTime: number, // when React started rendering this update
commitTime: number // when React committed it (shared by every Profiler in the commit)
) {}The two durations are the interesting part. actualDuration is what this update cost. baseDuration is the sum of the most recent render time of every component in the subtree: what it would cost if nothing were skipped. When memoization works, actualDuration drops well below baseDuration. When the two are always equal, nothing in the subtree is being skipped.
import { Profiler, useState, type ProfilerOnRenderCallback } from "react";
import { books, slowDown } from "guide-tools";
const onRender: ProfilerOnRenderCallback = (id, phase, actual, base) => {
console.log(`${id} ${phase}: actual ${actual.toFixed(1)} ms, base ${base.toFixed(1)} ms`);
};
function BookList({ query }: { query: string }) {
const visible = books.filter((b) =>
b.title.toLowerCase().includes(query.toLowerCase())
);
return <ul>{visible.map((b) => <li key={b.id}>{b.title}</li>)}</ul>;
}
function Stats() {
slowDown(60);
return <p>{books.length} books</p>;
}
export default function App() {
const [query, setQuery] = useState("");
return (
<div>
<input value={query} onChange={(e) => setQuery(e.target.value)} placeholder="Type here" />
<Profiler id="BookList" onRender={onRender}>
<BookList query={query} />
</Profiler>
<Profiler id="Stats" onRender={onRender}>
<Stats />
</Profiler>
</div>
);
}Each keystroke logs two lines with phase update: BookList costs a fraction of a millisecond, Stats about 60. You now have a number to beat, and you know where to work. (The fix, keeping Stats out of the keystroke's render, is chapter 29's job.)
Some facts about <Profiler> worth knowing:
- It's cheap but not free, so use it on the subtrees you're investigating, not everywhere.
- It's disabled in production builds.
onRendersimply isn't called. To measure production code you need React's profiling build, which you get by importingreact-dom/profilinginstead ofreact-dom/client(usually through a bundler alias). This is also how you'd send real-user render timings to your monitoring. phaseis"nested-update"when the update was scheduled during a commit, for example by asetStateinsideuseLayoutEffect. Those are worth hunting, because they mean React rendered twice before the browser could paint.
The React DevTools Profiler#
<Profiler> is for code. For investigating, you'll spend most of your time in the Profiler tab of React DevTools, the browser extension. It records every commit while you use the app and lets you inspect each one.
The workflow: open the Profiler tab, press record, do the slow thing (type in the search box), stop. Along the top you get one bar per commit, taller and warmer for slower ones. Click a commit to see it in two views:
Flamegraph view for one commit. Each bar is a component; its width is how long it and its children took to render. App is the whole commit (62 ms), and almost all of it sits under Stats.
- The flamegraph shows the component tree for that commit. Width is render time for a component and its children; color separates fast, slow and "didn't render". You read it top-down to find the subtree that ate the time.
- The ranked chart lists only the components that rendered in that commit, sorted by their own render time. It answers "which single component is slowest?" in one glance.
- Why did this render? If you enable "Record why each component rendered while profiling" in the Profiler settings, clicking a component tells you the cause: its parent rendered, specific props changed, a hook changed, and so on. "The parent component rendered" with no changed props is the signature of a component that memoization or a structural fix could skip.
Two more DevTools features help:
- Highlight updates when components render (in the settings) draws a flash around each component as it renders, on the real page. It's the fastest way to spot a whole sidebar re-rendering on every keystroke. The
<Rendered>box used in this guide's sandboxes is a homemade version of it. - The Components tab marks components the React Compiler optimized with a "Memo ✨" badge. Chapter 30 uses that.
React Performance tracks in Chrome React 19.2#
The DevTools Profiler shows React in isolation. Slowness usually involves more than React: a network request, a long JSON.parse, layout thrashing, a third-party script. Since React 19.2, React adds its own Performance tracks to the timeline in Chrome DevTools' Performance panel, so React's work sits on the same time axis as everything else the browser does.
One click, one long task on the main thread (60 ms, over the 50 ms long-task line). The Scheduler track splits React's share of it into phases: Update (what triggered it), Render (calling components), Commit (DOM changes and layout effects) and Remaining Effects (passive effects). This was a Blocking update; the Transition, Suspense and Idle rows stay empty.
There are two main groups:
- Scheduler: React's work by priority, in four subtracks. Blocking is synchronous work, usually from user input. Transition is work started with
startTransition. Suspense covers showing fallbacks and revealing content. Idle is the lowest priority. Each render pass is split into phases: Update (what caused it), Render (calling your components), Commit (applying DOM changes and running layout effects) and Remaining Effects (passive effects likeuseEffect). If an update is scheduled while React is rendering, a Cascading update entry flags it, and in development clicking it shows a stack trace naming what scheduled it. - Components: a flamegraph of component render durations, lined up under the Render phase, plus a separate flamegraph for effects (only effects that took at least 0.05 ms or caused an update are drawn). In development builds, clicking a component render shows which props changed. Mount and unmount events appear here too, and with
<Activity>(chapter 27) you'll see reconnect and disconnect.
There's also a Server group for Server Components and the promises they await. It only exists in development, and chapter 44 covers Server Components.
Availability matters. In development builds every track is on by default. In profiling builds, only the Scheduler tracks are on by default, and the Components track only lists components inside a <Profiler> unless the React DevTools extension is enabled. In plain production builds the instrumentation is off, because it costs time.
The browser's Performance panel#
React's tracks live inside the browser's own Performance panel, and the rest of that panel is where you find problems that aren't React's: slow scripts, style recalculation, layout and paint.
A short tour of what to look at:
- The main thread track. Every block is a task. Tasks longer than 50 ms are long tasks, marked with a red corner. While a long task runs, the browser can't respond to input, so long tasks during an interaction are exactly what users feel as lag.
- CPU throttling. Your laptop is much faster than your median user's phone. Record with 4x or 6x CPU slowdown to see what they see.
- Interactions. The panel lists interactions (clicks, key presses) with their duration, which maps directly onto INP below.
- The bottom-up and call tree views tell you which functions inside a long task took the time, including the ones in your components.
The habit to build: record, find the long task during the interaction, then look at what's inside it. If it's React's Render phase, the Components track tells you which component. If it's something else, React isn't your problem.
Core Web Vitals: what users feel#
Everything so far is lab data: you, on your machine, reproducing a problem. Core Web Vitals are Google's three user-centric metrics, measured on real users' devices (field data), and they're what most teams use to decide whether a page is fast enough.
| Metric | Measures | Good | Poor |
|---|---|---|---|
| LCP, Largest Contentful Paint | Loading: when the largest image or text block in the viewport rendered | 2.5 s or less | over 4 s |
| INP, Interaction to Next Paint | Responsiveness: from a user's click, tap or key press to the next frame painted, across the whole visit | 200 ms or less | over 500 ms |
| CLS, Cumulative Layout Shift | Visual stability: how much visible content moves unexpectedly | 0.1 or less | over 0.25 |
Between "good" and "poor" is "needs improvement". You assess each metric at the 75th percentile of page loads, separately for mobile and desktop, and a page passes only if all three are good. INP replaced First Input Delay (FID) as one of the Core Web Vitals in 2024. FID only measured the delay before the first interaction's handler started, which hid most real sluggishness.
Where React shows up in each:
- INP is the one your component code moves most directly. An interaction's latency is input delay (the main thread was busy when the user acted), plus processing time (your event handlers and the React render and commit they trigger), plus presentation delay (layout and paint of the new frame). A 60 ms Stats render on every keystroke goes straight into processing time. Transitions (chapter 24) help because urgent updates no longer wait behind slow ones; memoization (chapter 29) helps by skipping the slow work.
- LCP depends on how fast the main content appears. A client-rendered app can't paint content until its JavaScript downloads, parses and renders, which is why bundle size (chapter 31) and server rendering (Part 7) matter so much here.
- CLS comes from content that arrives late and pushes things around: images without dimensions, a Suspense fallback that's much smaller than the content replacing it, a banner inserted above the fold.
To collect them from real users, the small web-vitals library reports each metric with a callback (onLCP, onINP, onCLS), and Next.js wraps that in useReportWebVitals. Send them to whatever analytics you use and watch the 75th percentile, not the average.
import { onCLS, onINP, onLCP } from "web-vitals";
function send(metric: { name: string; value: number; rating: string }) {
navigator.sendBeacon("/analytics", JSON.stringify(metric));
}
onLCP(send);
onINP(send);
onCLS(send);A workflow that works#
Put together, investigating a performance complaint looks like this:
- Reproduce it on a realistic device: a production build, CPU throttling on, real-sized data.
- Record it in the Performance panel. Find the long task or slow interaction. Decide whether it's React at all.
- If it is, find the component: the Components track or the DevTools Profiler's ranked view, then "why did this render".
- Fix one thing: often moving state, sometimes memoization, sometimes a transition, sometimes doing less work.
- Measure again, the same way. Keep the fix only if the number moved.
- For ongoing protection, watch the field metrics (INP especially) and, for critical subtrees, a
<Profiler>on the profiling build.
Pitfalls#
Check your understanding#
In the <Profiler> sandbox above, suppose Stats were wrapped so that React skips it when its parent re-renders (that's memo, next chapter). You type one more letter. What does the Stats profiler log: does onRender still fire, and what are roughly the actual and base durations?
This dashboard has three panels, and one of them makes typing slow. Don't read the panel code to find it. Instead, wrap each panel in a <Profiler>, add up each panel's actualDuration across renders, and make the Show report button display Slowest: <id> for the panel with the largest total. Press Check when it works.
import { useState } from "react";
import { Filters, Chart, Feed } from "./panels";
export default function App() {
const [query, setQuery] = useState("");
const [report, setReport] = useState("Slowest: ?");
return (
<div>
<input aria-label="search" value={query} onChange={(e) => setQuery(e.target.value)} />
<Filters query={query} />
<Chart query={query} />
<Feed query={query} />
<button onClick={() => setReport("Slowest: ?")}>Show report</button>
<p id="report">{report}</p>
</div>
);
}Users say typing in your search box feels sluggish on phones. Which of the Core Web Vitals captures this, and what's the 'good' threshold?
In React's Scheduler track you see a render in the Blocking subtrack, immediately followed by a 'Cascading update' and a second Blocking render. What's the most likely cause?
An interviewer says: "A product manager tells you the dashboard feels slow. Walk me through what you do." Answer in about a minute.
Interview angle
I don't optimize React code until I've measured it, because the slow component is rarely the one you'd guess and every optimization adds complexity. I reproduce the problem on a production build with CPU throttling, record it in Chrome's Performance panel, and check whether the long task is React at all. If it is, React's Performance tracks or the DevTools Profiler show which component took the time and why it rendered. I fix the one thing that dominates and measure again. For real users I watch Core Web Vitals at the 75th percentile, especially INP for responsiveness.
What's the difference between actualDuration and baseDuration in the Profiler's onRender callback?
What are the Core Web Vitals, and what are the thresholds?
How does a slow React render show up in INP, and what can you do about it?
When would you use the React DevTools Profiler versus the Performance tracks in Chrome DevTools?
Why shouldn't you trust profiling numbers from the development build?
Your colleague wants to wrap every component in memo because DevTools shows lots of re-renders. What do you say?
Recap#
- Measure before optimizing. The slow component is rarely the one you'd guess, and every optimization has a cost.
<Profiler>reportsactualDuration(what this update cost) andbaseDuration(what it would cost with nothing skipped). It's off in production unless you use the profiling build.- The DevTools Profiler's flamegraph, ranked view and "why did this render" find the slow component and the reason it rendered.
- React 19.2's Performance tracks put React's Scheduler phases and component flamegraph on Chrome's timeline, next to network, scripts and layout.
- Core Web Vitals (LCP 2.5 s, INP 200 ms, CLS 0.1, at the 75th percentile) are the field metrics that say whether users suffer. INP is the one React rendering moves most.
Sources#
- react.dev:
<Profiler> - react.dev: React Performance tracks
- react.dev: React 19.2 release post
- react.dev: React Developer Tools
- web.dev: Web Vitals and How the Core Web Vitals thresholds were defined
- web.dev: Interaction to Next Paint
- Chrome for Developers: Analyze runtime performance
- Facts checked November 24, 2026.