Getting started with Speed Insights
This guide shows how to enable Vercel Speed Insights, add it to an application, deploy the change, and read the resulting data.
Speed Insights tracks real-time application performance, including Core Web Vitals, so you can identify user-facing performance problems.
Prerequisites
You need:
- A Vercel account. You can sign up for free.
- A Vercel project. You can create a new project if you don't have one.
- The Vercel CLI. Install it with one of these commands:
- pnpm
- yarn
- npm
- bun
pnpm i vercel
yarn add vercel
npm i vercel
bun add vercel
Setup
Step 1: enable Speed Insights in Vercel
On the Vercel dashboard, select your project, click the Speed Insights tab, and then click Enable in the dialog.
Enabling Speed Insights adds new routes (scoped at /_vercel/speed-insights/*) after your next deployment.
Step 2: add @vercel/speed-insights to your project
The installation process varies by framework. HTML projects do not require package installation.
For most frameworks (Next.js, React, Remix, SvelteKit, Vue, Nuxt, Astro), install the package using your preferred package manager:
- pnpm
- yarn
- npm
- bun
pnpm i @vercel/speed-insights
yarn add @vercel/speed-insights
npm i @vercel/speed-insights
bun add @vercel/speed-insights
If you're using the HTML implementation, you don't need to install the @vercel/speed-insights package. Skip to the HTML integration section later in this guide.
Step 3: integrate Speed Insights into your application
The integration method depends on your framework. Choose the section for your framework:
Framework-specific integration
Next.js (Pages Router)
The SpeedInsights component wraps the tracking script for Next.js.
Add the component to your pages/_app.tsx or pages/_app.jsx file:
- TypeScript
- JavaScript
import type { AppProps } from 'next/app';
import { SpeedInsights } from '@vercel/speed-insights/next';
function MyApp({ Component, pageProps }: AppProps) {
return (
<>
<Component {...pageProps} />
<SpeedInsights />
</>
);
}
export default MyApp;
import { SpeedInsights } from '@vercel/speed-insights/next';
function MyApp({ Component, pageProps }) {
return (
<>
<Component {...pageProps} />
<SpeedInsights />
</>
);
}
export default MyApp;
For versions of Next.js older than 13.5, import from @vercel/speed-insights/react and pass the pathname:
- TypeScript
- JavaScript
import { SpeedInsights } from '@vercel/speed-insights/react';
import { useRouter } from 'next/router';
export default function Layout() {
const router = useRouter();
return <SpeedInsights route={router.pathname} />;
}
import { SpeedInsights } from '@vercel/speed-insights/react';
import { useRouter } from 'next/router';
export default function Layout() {
const router = useRouter();
return <SpeedInsights route={router.pathname} />;
}
Next.js (App Router)
Add the SpeedInsights component to your root layout:
- TypeScript
- JavaScript
import { SpeedInsights } from '@vercel/speed-insights/next';
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<head>
<title>Next.js</title>
</head>
<body>
{children}
<SpeedInsights />
</body>
</html>
);
}
import { SpeedInsights } from '@vercel/speed-insights/next';
export default function RootLayout({ children }) {
return (
<html lang="en">
<head>
<title>Next.js</title>
</head>
<body>
{children}
<SpeedInsights />
</body>
</html>
);
}
Create a dedicated client component to avoid opting out from SSR on the layout:
- TypeScript
- JavaScript
'use client';
import { SpeedInsights } from '@vercel/speed-insights/react';
import { usePathname } from 'next/navigation';
export function Insights() {
const pathname = usePathname();
return <SpeedInsights route={pathname} />;
}
'use client';
import { SpeedInsights } from '@vercel/speed-insights/react';
import { usePathname } from 'next/navigation';
export function Insights() {
const pathname = usePathname();
return <SpeedInsights route={pathname} />;
}
Then import in your layout:
- TypeScript
- JavaScript
import type { ReactNode } from 'react';
import { Insights } from './insights';
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en">
<head>
<title>Next.js</title>
</head>
<body>
{children}
<Insights />
</body>
</html>
);
}
import { Insights } from './insights';
export default function RootLayout({ children }) {
return (
<html lang="en">
<head>
<title>Next.js</title>
</head>
<body>
{children}
<Insights />
</body>
</html>
);
}
Create React App
Add the SpeedInsights component to your main app file:
- TypeScript
- JavaScript
import { SpeedInsights } from '@vercel/speed-insights/react';
export default function App() {
return (
<div>
{/* Your app content */}
<SpeedInsights />
</div>
);
}
import { SpeedInsights } from '@vercel/speed-insights/react';
export default function App() {
return (
<div>
{/* Your app content */}
<SpeedInsights />
</div>
);
}
Remix
Add the SpeedInsights component to your root file:
- TypeScript
- JavaScript
import { SpeedInsights } from '@vercel/speed-insights/remix';
export default function App() {
return (
<html lang="en">
<body>
{/* Your app content */}
<SpeedInsights />
</body>
</html>
);
}
import { SpeedInsights } from '@vercel/speed-insights/remix';
export default function App() {
return (
<html lang="en">
<body>
{/* Your app content */}
<SpeedInsights />
</body>
</html>
);
}
SvelteKit
Call the injectSpeedInsights function in your root layout:
- TypeScript
- JavaScript
import { injectSpeedInsights } from '@vercel/speed-insights/sveltekit';
injectSpeedInsights();
import { injectSpeedInsights } from '@vercel/speed-insights/sveltekit';
injectSpeedInsights();
Vue
Add the SpeedInsights component to your main app template:
- TypeScript
- JavaScript
<script setup lang="ts">
import { SpeedInsights } from '@vercel/speed-insights/vue';
</script>
<template>
<SpeedInsights />
<!-- Your app content -->
</template>
<script setup>
import { SpeedInsights } from '@vercel/speed-insights/vue';
</script>
<template>
<SpeedInsights />
<!-- Your app content -->
</template>
Nuxt
Add the SpeedInsights component to your default layout:
- TypeScript
- JavaScript
<script setup lang="ts">
import { SpeedInsights } from '@vercel/speed-insights/vue';
</script>
<template>
<SpeedInsights />
<!-- Your app content -->
</template>
<script setup>
import { SpeedInsights } from '@vercel/speed-insights/vue';
</script>
<template>
<SpeedInsights />
<!-- Your app content -->
</template>
Astro
Speed Insights is available for both static and SSR Astro apps. Declare the <SpeedInsights /> component near the bottom of a layout component:
- TypeScript
- JavaScript
---
import SpeedInsights from '@vercel/speed-insights/astro';
const { title, description } = Astro.props;
---
<title>{title}</title>
<meta name="title" content={title} />
<meta name="description" content={description} />
<SpeedInsights />
---
import SpeedInsights from '@vercel/speed-insights/astro';
const { title, description } = Astro.props;
---
<title>{title}</title>
<meta name="title" content={title} />
<meta name="description" content={description} />
<SpeedInsights />
Optional: remove sensitive information
You can remove sensitive information from URLs by adding a speedInsightsBeforeSend function:
- TypeScript
- JavaScript
---
import SpeedInsights from '@vercel/speed-insights/astro';
const { title, description } = Astro.props;
---
<title>{title}</title>
<meta name="title" content={title} />
<meta name="description" content={description} />
<script is:inline>
function speedInsightsBeforeSend(data) {
console.log('Speed Insights before send', data);
return data;
}
</script>
<SpeedInsights />
---
import SpeedInsights from '@vercel/speed-insights/astro';
const { title, description } = Astro.props;
---
<title>{title}</title>
<meta name="title" content={title} />
<meta name="description" content={description} />
<script is:inline>
function speedInsightsBeforeSend(data) {
console.log('Speed Insights before send', data);
return data;
}
</script>
<SpeedInsights />
HTML (Vanilla JavaScript)
Add the following scripts before the closing </body> tag:
<script>
window.si = window.si || function () { (window.siq = window.siq || []).push(arguments); };
</script>
<script defer src="/_vercel/speed-insights/script.js"></script>
Other frameworks
For frameworks not explicitly listed, use the generic integration:
- TypeScript
- JavaScript
import { injectSpeedInsights } from '@vercel/speed-insights';
injectSpeedInsights();
import { injectSpeedInsights } from '@vercel/speed-insights';
injectSpeedInsights();
Call this function only once in your app. It must run in the client.
Step 4: deploy your app to Vercel
Deploy your app to Vercel's global CDN by running the following command from your terminal:
vercel deploy
Alternatively, you can connect your project's Git repository, which lets Vercel deploy your latest pushes and merges to main.
After your app is deployed, it starts tracking performance metrics.
If everything is set up correctly, you can find the /_vercel/speed-insights/script.js script inside the body tag of your page.
Step 5: view your data in the dashboard
After your app is deployed and users have visited your site, you can view the data in the dashboard.
To do so:
- Go to your Vercel dashboard.
- Select your project.
- Click the Speed Insights tab.
After a few days of visitors, you can start exploring your metrics.
Privacy and compliance
Learn more about how Vercel supports privacy and data compliance standards with Vercel Speed Insights.
Next steps
To go further with Speed Insights:
- Learn how to use the
@vercel/speed-insightspackage - Learn about metrics
- Read about privacy and compliance
- Explore pricing
- Troubleshooting
Summary
Setup takes four steps: enable Speed Insights in the Vercel dashboard, install the package, integrate the component for your framework, and deploy. The tracking script runs client side and reports Core Web Vitals to Vercel. Data appears in the dashboard after users visit your deployed site.
Related documentation:
- Fast Feedback - Learn about monitoring and observability practices
- Software Delivery Performance - Understand metrics-driven delivery optimization
- AI-powered SDLC with Claude Code - this page, like every page on this site, is written and maintained through Claude Code