@vercel/speed-insights

Overview
@vercel/speed-insights automatically tracks web vitals and other performance metrics for your website.
This package does not track data in development mode.
It has 1st class integration with:
| Framework | Package |
|---|---|
| Next.js | @vercel/speed-insights/next |
| Nuxt | @vercel/speed-insights/nuxt |
| SvelteKit | @vercel/speed-insights/sveltekit |
| SvelteKit 3 | @vercel/speed-insights/sveltekit-next |
| Remix | @vercel/speed-insights/remix |
| React | @vercel/speed-insights/react |
| Astro | @vercel/speed-insights/astro |
| Vue | @vercel/speed-insights/vue |
It also supports other frameworks, vanilla JS and static websites.
Quickstart
- Enable Vercel Speed Insights for a project in the Vercel Dashboard.
- Add the
@vercel/speed-insightspackage to your project - Inject Speed Insights to your app
- If you are using Next.js, React, Nuxt or Vue you can use the framework-specific
<SpeedInsights />component to inject the script into your app. - If you are using SvelteKit 2, you can use the
injectSpeedInsights()function from@vercel/speed-insights/sveltekitin your top-level+layout.js/tsfile. - If you are using SvelteKit 3, import
injectSpeedInsights()from@vercel/speed-insights/sveltekit-nextinstead. - For other frameworks, you can use the
injectfunction add the tracking script to your app. - If you want to use Vercel Speed Insights on a static site without npm, follow the instructions in the documentation.
- If you are using Next.js, React, Nuxt or Vue you can use the framework-specific
- Deploy your app to Vercel and see data flowing in.
Soft navigations
To disable performance reporting for client-side navigations, set softNavs to false when you initialize Speed Insights. Hard-navigation reporting is not affected.
For React, Next.js, Remix, and Astro components:
<SpeedInsights softNavs={false} />
For Vue and Nuxt components, bind the boolean value:
<SpeedInsights :soft-navs="false" />
For injectSpeedInsights, including the SvelteKit and Nuxt runtime integrations:
injectSpeedInsights({ softNavs: false });
For the Nuxt module, set the option in nuxt.config.ts (see Nuxt module options):
export default defineNuxtConfig({
modules: ['@vercel/speed-insights'],
speedInsights: { softNavs: false },
})
Nuxt module options
The Nuxt module passes its options through to the client plugin, so you can configure it from nuxt.config.ts:
export default defineNuxtConfig({
modules: ['@vercel/speed-insights'],
speedInsights: {
sampleRate: 0.25,
},
})
Supported options are dsn, sampleRate, debug, softNavs, scriptSrc, and endpoint. To configure the beforeSend middleware, use a custom plugin.
Documentation
Find more details about this package in our documentation.