Skip to content

Fixing LCP, INP, and CLS in a Real React 19 Application

How to measure and fix LCP, INP, and CLS in a real React 19 app, with the exact tools and code changes that move each metric into the green.

· · 7 min read

Updated: November 23, 2026

Table of layout shift causes in React apps: unsized images, late ad slots, skeletons and font swaps

Quick Take

LCP, INP, and CLS are the three Core Web Vitals Google uses for ranking in 2026. Automatic batching (on by default since React 18) trims extra re-renders, but a slow re-render after a click still blocks the next paint unless you mark it non-urgent with `startTransition` or `useDeferredValue`. Fix LCP by preloading your hero image and font, fix CLS by reserving space for late-loading content, and measure everything with field data, not just Lighthouse.

Core Web Vitals are the three field-measured performance metrics, LCP, INP, and CLS, that Google folds into ranking, and getting them green in a React 19 app requires different fixes for each one. A React 19 dashboard can score 98 on Lighthouse and still get flagged for poor INP in Search Console three weeks later. Lighthouse runs in a lab environment on a clean load. Real users click buttons after 40 browser tabs are open and a half-loaded ad script is still parsing. That gap between lab and field data is where most Core Web Vitals advice falls apart, so this guide sticks to what actually changes a real INP number.

Why lab scores and field data disagree

Lighthouse measures a single page load on a simulated mid-tier phone with no interaction. Core Web Vitals, the ones Google actually uses for ranking, come from the Chrome User Experience Report (CrUX), aggregated from real Chrome users over a rolling 28-day window. A 98 Lighthouse score tells you your best-case load is fast. It says nothing about what happens when a real visitor on a three-year-old Android phone clicks "Add to Cart" while three background scripts are still running.

Check Search Console's Core Web Vitals report before you trust any lab number. That report is field data, and when it disagrees with Lighthouse, it's the one to believe. Fixing a number that only exists in the lab doesn't change what the application's real users get.

LCP: where React apps get it wrong

Largest Contentful Paint measures when the biggest visible element finishes rendering. In a React app, that element is often a hero image or a headline that only appears after your JavaScript bundle downloads, parses, and runs. Server-side rendering with Astro or Next.js closes most of that gap, but two mistakes still show up constantly:

  1. The LCP image isn't preloaded. If your hero image loads through a <img> tag discovered only after React hydrates, the browser starts fetching it too late.
  2. Web fonts block text rendering. A blocking @font-face without font-display: swap delays the text paint until the font file arrives.
<!-- In your document head, before any JS -->
<link rel="preload" as="image" href="/images/hero.webp" fetchpriority="high" />
<link rel="preload" as="font" href="/fonts/inter-var.woff2" type="font/woff2" crossorigin />

No React code changes here, just the resource priority the browser is told to use. Measure LCP before and after on a throttled profile, because how much it moves depends on how late the image was being discovered.

INP: what React 19 does for you and what it doesn't

INP measures the full round trip of an interaction: input, processing, and the next visual update. React batches state updates automatically across almost every context, including timeouts and promises, a change that shipped in React 18 and carries over to 19; in React 17 and earlier, updates outside event handlers were a common source of extra re-renders.

Automatic batching, on by default since React 18, is a real win for INP, but it doesn't mean your click handlers are fast by default.

Share this Post on X Bluesky

Have you ever profiled a "simple" button click and found it triggers four component re-renders before the UI updates? That's the usual INP killer. The fix is startTransition (or useDeferredValue), which tells React a state update isn't urgent, so the render it triggers can be interrupted by the next keystroke or click. In one 1000-row test, a measured startTransition click delay dropped from 203 ms to 5 ms.

// Before: every keystroke blocks the next paint
function SearchBox() {
  const [query, setQuery] = useState('');
  const [results, setResults] = useState([]);

  function handleChange(e) {
    setQuery(e.target.value);
    setResults(filterLargeDataset(e.target.value)); // slow, synchronous
  }

  return <input value={query} onChange={handleChange} />;
}

// After: the input stays responsive, the results re-render is deferred
import { memo, useDeferredValue, useState } from 'react';

const Results = memo(function Results({ query }) {
  const items = filterLargeDataset(query); // runs in the deferred render
  return (
    <ul>
      {items.map((item) => <ResultRow key={item.id} item={item} />)}
    </ul>
  );
});

function SearchBox() {
  const [query, setQuery] = useState('');
  const deferredQuery = useDeferredValue(query);

  return (
    <>
      <input value={query} onChange={(e) => setQuery(e.target.value)} />
      <Results query={deferredQuery} />
    </>
  );
}

The input field updates instantly because setQuery is an urgent update. Results re-renders with the deferred query in a background render, and React throws that render away if a new keystroke arrives. One limit: a concurrent render yields to the browser between components, not inside one, so what gets sliced up is rendering hundreds of ResultRows. A single filterLargeDataset call that takes 200 ms on its own still blocks the main thread for 200 ms, and that one needs chunking or a Web Worker. Wrapping the same synchronous filter in startTransition inside the handler, the way the "before" code invites, fixes nothing, because the transition callback runs immediately, inside the click. Deferring the render is the trick, and for a list that re-renders on every keystroke it's usually the biggest INP fix available.

Reserving space before content exists (CLS)

Cumulative Layout Shift is the Core Web Vitals metric that scores how much visible content unexpectedly moves during a page's lifetime, calculated from the fraction of the viewport that shifts multiplied by the distance it moves. In React apps it's almost always one of three causes: images without dimensions, ads or embeds that inject late, or a loading skeleton that's a different size than the real content. Per the Chrome for Developers thresholds page, a CLS score under 0.1 counts as good, 0.1 to 0.25 needs improvement, and anything above 0.25 is poor, measured at the 75th percentile of real visits. Of those three, images without dimensions are the cheapest to fix: explicit width and height attributes on every image tag let the browser reserve the box before the file arrives, with no CSS or JavaScript changes needed.

CauseFix
Image without width/heightAlways set explicit width/height or use aspect-ratio in CSS
Late-loading ad slotReserve a fixed-height container before the ad script runs
Skeleton loader mismatchMatch the skeleton's exact dimensions to the loaded content
Web font swapUse font-display: optional for above-the-fold text, or preload the font

You don't need a custom aspect-ratio rule for this: every current browser derives a default aspect ratio from the width and height attributes, so ship both on every <img> tag and pair them with height: auto whenever CSS sets the width, even when you're using object-fit: cover to crop it.

Tools that measure real users

  • Chrome DevTools Performance panel with the "Interactions" track enabled shows exactly which handler caused a slow INP entry, down to the component.
  • web-vitals npm package ships an onINP, onLCP, and onCLS API you can wire into your own analytics, so you get field data from your actual users instead of guessing from Lighthouse.
  • PageSpeed Insights combines lab data (Lighthouse) with field data (CrUX) on the same report, which is the fastest way to spot a lab/field mismatch without setting up your own logging.
import { onINP, onLCP, onCLS } from 'web-vitals';

onINP(metric => sendToAnalytics('INP', metric.value));
onLCP(metric => sendToAnalytics('LCP', metric.value));
onCLS(metric => sendToAnalytics('CLS', metric.value));

Wire this up once, and you stop guessing whether a deploy helped or hurt. I'd rather see three weeks of real INP data trend down than a single Lighthouse run hit 100. To see which interaction and which phase sits behind the number, this INP debugging walkthrough uses the attribution build end to end.

Which fix comes first?

Not every regression is worth chasing immediately. Start with whichever metric is failing in Search Console's field data, not the one that looks worst in a synthetic test. If INP is failing, profile your three most-clicked interactive elements first, since the interactions people repeat most are the ones that weigh most in the 75th-percentile score. If LCP is failing, check your hero image and font loading before anything else. CLS failures are usually quick to fix once you find the culprit element in the DevTools Layout Shift regions overlay. One caveat before you blame React: if the slow handler turns out to be a scroll listener driving an animation, no amount of startTransition will save it, because the work is on the main thread by construction. CSS scroll-driven animations move that same effect off the main thread entirely, and deleting the listener beats optimizing it.

Frequently Asked Questions

What are the three Core Web Vitals in 2026?
Largest Contentful Paint (LCP, loading speed), Interaction to Next Paint (INP, responsiveness), and Cumulative Layout Shift (CLS, visual stability). INP replaced First Input Delay as the official responsiveness metric in March 2024, and it's the one that trips up most React apps because it measures the full interaction, not just the first millisecond of it.
Why does React 19 make INP harder to control than older versions?
It doesn't, really, React 19 actually helps if you use it right. The problem is that React apps tend to pile state updates and re-renders into a single click handler, and every one of those runs synchronously unless you explicitly defer it. Automatic batching (React 18 and later) and startTransition give you the tools to fix this, but they don't fix it for you. You still have to find the slow update and mark it non-urgent, and slow synchronous code inside the handler itself blocks the main thread no matter what you wrap it in.
What INP score counts as 'good' in 2026?
Under 200 milliseconds is good, 200 to 500 milliseconds needs improvement, and anything over 500 milliseconds is poor, per Google's official thresholds. The target applies to the 75th percentile of real user interactions on your site, not your best-case click in a fast laptop with dev tools closed.