Core Web Vitals in Next.js
What LCP, INP and CLS measure, which Next.js features target each, the difference between lab and field data, and how to report vitals with a hook.
Core Web Vitals in Next.js
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- The three Core Web Vitals are LCP (good at 2.5s or less), INP (200ms or less) and CLS (0.1 or less), judged at the 75th percentile of real visits.
- LCP is helped by `next/image` with early loading on only the hero image, streaming, and static rendering; CLS by reserved image space and `next/font` fallbacks.
- INP is a main-thread problem: ship less client JavaScript, split large client components, and control third-party script strategy.
- Use field data to find out whether you have a problem and lab data such as Lighthouse on a production build to find why.
What Core Web Vitals measure
“Fast” is not one number. Google settled on three that capture how a page feels to a real person, and it uses them in search ranking:
- Largest Contentful Paint (LCP): how long until the biggest thing in the viewport, usually a hero image or a headline, is drawn. Good is 2.5 seconds or less.
- Interaction to Next Paint (INP): how long the page takes to visibly respond after a click, tap or keypress, across the whole visit. Good is 200 milliseconds or less. It replaced First Input Delay as the responsiveness metric in 2024.
- Cumulative Layout Shift (CLS): how much visible content jumps around while loading. Good is 0.1 or less.
These are judged at the 75th percentile of real visits, which matters: your fast laptop is not the data. The slowest quarter of your users decides the score.
Mapping each metric to a Next.js lever
Next.js ships features that each target one of these. The skill is knowing which problem you have.
LCP. The usual cause is a slow hero image or a late server response. Use next/image with the right sizes and mark only the LCP image for early loading (preload in Next.js 16, which replaced the deprecated priority, or fetchPriority="high"). Do not preload five images; that cancels the benefit. Stream the rest of the page with loading.tsx or <Suspense> so a slow query does not hold up the shell. Static and cached rendering gets HTML to the browser fastest of all, as the caching and rendering lessons showed.
CLS. Layout shift comes from things that arrive without reserved space. next/image reserves space from width and height. next/font generates a fallback font with matching metrics, so the text does not reflow when the real font loads. Both were earlier lessons. The remaining cause is content you inject yourself, such as an ad slot or a banner that pushes the page down; give it a fixed height up front.
INP. This one is about JavaScript on the main thread, not the network. A long task, such as hydrating a large client component tree or running heavy work in a click handler, blocks the browser from painting the response. Ship less client code (the previous lesson), move work to Server Components, split big client components, and for expensive updates use React’s transitions so urgent input is not blocked. Third-party scripts are a common culprit, which is why strategy matters in next/script.
Measuring: lab versus field
Two kinds of data answer different questions. Lab data, from Lighthouse in Chrome DevTools, is a synthetic run you can repeat and debug, but it is one device on one network. Field data, collected from real users, is what Google actually scores, but it only tells you the number, not the cause. Use field data to find out whether you have a problem and lab data to find why. Lighthouse on a production build, not next dev, since the dev server does extra work and sends unminified code.
To collect field data yourself, Next.js provides a hook that reports each metric as it is measured:
// app/_components/web-vitals.tsx
"use client";
import { useReportWebVitals } from "next/web-vitals";
export function WebVitals() {
useReportWebVitals((metric) => {
// send to your analytics endpoint
navigator.sendBeacon("/api/vitals", JSON.stringify(metric));
});
return null;
}
Render <WebVitals /> in your root layout. The docs warn that the callback’s reference must not change between renders, or you will report duplicates, so define it outside the component or memoize it. The metric object includes the name (LCP, INP, CLS and others), its value, and a rating.
A way to work
Do not optimize in the abstract. Measure the page that matters most, find which of the three is failing, apply the lever that targets it, and measure again. Fixing CLS on a page whose real problem is a 4-second LCP is wasted work.
What the video covers
Syntax’s “Web Vitals Explained” is a 22-minute chaptered discussion from March 2025 in which Scott and Wes explain LCP, FCP, CLS, INP and TTFB, how each affects a site, and how to track them yourself; they then check their own sites. It is general web performance, not Next.js, so the mapping to next/image, next/font, streaming and useReportWebVitals comes from this lesson. A 3-minute Blazity video on fixing LCP in Next.js is listed under “deeper”.
Where this fits
Performance is one side of quality. The other is knowing your app still works after you change it. Next: unit and component testing.
Check yourself
Which metric is mostly about JavaScript on the main thread rather than the network?
INP, because long tasks such as heavy hydration or slow click handlers delay the next paint after an interaction.
Why measure with Lighthouse on a production build rather than `next dev`?
The dev server compiles on demand and sends unminified code, so its numbers do not represent what users get.
Why must the callback passed to `useReportWebVitals` keep a stable reference?
A changing function reference causes the same metrics to be reported more than once.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.