Web Vitals

Report Core Web Vitals from the browser SDK

Add the Web Vitals extension to report LCP, CLS, INP, FCP, and TTFB from visitor sessions.

Enable Web Vitals

Import the extension from its package subpath. It takes no options.

import { webVitals } from "@faststats/react/web-vitals";

<Analytics siteKey="your_site_key" extensions={[webVitals()]} />;
nuxt.config.ts
faststats: {
	siteKey: "your_site_key",
	extensions: { webVitals: true },
}
import { init } from "@faststats/web";
import { webVitals } from "@faststats/web/web-vitals";

init({
	siteKey: "your_site_key",
	extensions: [webVitals()],
});

Collected Metrics

The tracker reports the following metrics.

MetricName
LCPLargest Contentful Paint
CLSCumulative Layout Shift
INPInteraction to Next Paint
FCPFirst Contentful Paint
TTFBTime to First Byte

Each metric is sent with its value, an id, a rating, the navigation type, and the delta since the last successfully sent value. Metrics are flushed when the page is hidden and when the client stops, and are attributed to the URL the document was loaded on.

Attribution

Attribution data is always included. Every metric carries the web-vitals attribution fields that point to the element, resource, or interaction responsible for it, such as the LCP element or the INP interaction target. There is nothing to turn on.