Skip to main content
Next.js has built-in support for measuring and reporting Core Web Vitals—the metrics used by Google to evaluate real-world page performance.

Web Vitals

The following metrics are reported:

useReportWebVitals

The useReportWebVitals hook is called every time a metric value is available in the browser:
app/components/WebVitals.tsx
Render the component in your root layout:
Because useReportWebVitals requires the 'use client' directive, create a separate component for it rather than adding it directly to the root layout (which is a Server Component).

The metric object

The metric argument passed to the callback has the following shape:
string
A unique identifier for the metric in the context of the current page load.
string
The metric name. One of 'TTFB', 'FCP', 'LCP', 'FID', 'CLS', 'INP'.
number
The metric value. For time-based metrics, the unit is milliseconds. For CLS, it is a unitless score.
number
The delta between the current value and the last reported value. Useful for calculating the total value when sending to analytics.
string
The qualitative rating of the metric. One of 'good', 'needs-improvement', or 'poor'.
string
How the page was loaded. One of 'navigate', 'reload', 'back-forward', 'back-forward-cache', 'prerender'.

Sending metrics to an analytics service

Send metrics to any analytics service inside the useReportWebVitals callback. The following examples show common integrations:
app/components/WebVitals.tsx

Vercel Speed Insights

Vercel provides Speed Insights as a built-in analytics product for applications deployed on Vercel. No additional code is required—Speed Insights is enabled automatically in the Vercel dashboard. For self-hosted deployments or to collect metrics manually, use the useReportWebVitals hook as shown above.

Performance budget

Use the rating field to alert when metrics fall outside acceptable ranges:
app/components/WebVitals.tsx