Install Vercel Speed Insights for Next.js

## Vercel Speed Insights Implementation

Successfully installed and configured Vercel Speed Insights for this Next.js portfolio project.

### What was implemented:

1. **Installed @vercel/speed-insights package**
   - Used npm (the project's package manager) to install `@vercel/speed-insights` v1.3.1
   - Updated package.json and package-lock.json with the new dependency

2. **Added SpeedInsights component to root layout**
   - Modified `app/layout.tsx` to import SpeedInsights from '@vercel/speed-insights/next'
   - Added the `<SpeedInsights />` component inside the `<body>` tag, after the main content
   - Placement follows Next.js App Router best practices for Next.js 15.5.12

### Files Modified:
- `app/layout.tsx` - Added import and component
- `package.json` - Added @vercel/speed-insights dependency
- `package-lock.json` - Updated with new dependency tree

### Implementation Details:
- The project uses Next.js 15.5.12 with App Router, which is newer than 13.5+
- Used the simplified approach: imported from '@vercel/speed-insights/next'
- No 'use client' directive needed as the package handles this internally
- The component is placed at the end of the body tag for optimal performance

### Verification:
- Build completed successfully with `npm run build`
- No errors or warnings introduced
- All changes have been staged with git

The Speed Insights component will now automatically track Core Web Vitals and send analytics data to Vercel when deployed.

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
This commit is contained in:
Vercel 2026-02-13 09:12:29 +00:00
parent 6d8f2f6e2d
commit 74ebc52437
3 changed files with 38 additions and 0 deletions

View file

@ -6,6 +6,7 @@ import Header from "./components/Header";
import Image from "next/image";
import logo from "./logo.png"
import Link from "next/link";
import { SpeedInsights } from '@vercel/speed-insights/next';
export const metadata: Metadata = {
title: "Portfolio - Mike Karl",
@ -34,6 +35,7 @@ export default function RootLayout({
{children}
</main>
<div className="bg" />
<SpeedInsights />
</body>
</html>
);

35
package-lock.json generated
View file

@ -8,6 +8,7 @@
"name": "portfolio",
"version": "0.1.0",
"dependencies": {
"@vercel/speed-insights": "^1.3.1",
"framer-motion": "^12.33.0",
"next": "^15.5.12",
"react": "19.1.0",
@ -1045,6 +1046,40 @@
"@types/react": "^19.2.0"
}
},
"node_modules/@vercel/speed-insights": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@vercel/speed-insights/-/speed-insights-1.3.1.tgz",
"integrity": "sha512-PbEr7FrMkUrGYvlcLHGkXdCkxnylCWePx7lPxxq36DNdfo9mcUjLOmqOyPDHAOgnfqgGGdmE3XI9L/4+5fr+vQ==",
"license": "Apache-2.0",
"peerDependencies": {
"@sveltejs/kit": "^1 || ^2",
"next": ">= 13",
"react": "^18 || ^19 || ^19.0.0-rc",
"svelte": ">= 4",
"vue": "^3",
"vue-router": "^4"
},
"peerDependenciesMeta": {
"@sveltejs/kit": {
"optional": true
},
"next": {
"optional": true
},
"react": {
"optional": true
},
"svelte": {
"optional": true
},
"vue": {
"optional": true
},
"vue-router": {
"optional": true
}
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001751",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001751.tgz",

View file

@ -8,6 +8,7 @@
"start": "next start"
},
"dependencies": {
"@vercel/speed-insights": "^1.3.1",
"framer-motion": "^12.33.0",
"next": "^15.5.12",
"react": "19.1.0",