Skip to content

Commit a2f06f7

Browse files
authored
Add Vercel Speed Insights to Next.js (#60)
## Vercel Speed Insights Implementation Successfully installed and configured Vercel Speed Insights for this Next.js project. ### Changes Made: 1. **Installed Package** - Added `@vercel/speed-insights` version 1.3.1 to dependencies - Updated package.json and package-lock.json 2. **Modified Files** - **pages/_app.js**: Added SpeedInsights component integration - Imported `SpeedInsights` from '@vercel/speed-insights/next' - Added `<SpeedInsights />` component inside the ThemeProvider, after the Layout component - This ensures Speed Insights tracks all pages in the application 3. **Project Context** - This is a Next.js 16.1.6 project using the Pages Router - The implementation follows the recommended pattern for Pages Router applications - The SpeedInsights component is placed at the app level to track all routes ### Implementation Details: The SpeedInsights component was added to the root `_app.js` file, which ensures it's included on every page of the application. The component is self-contained and will automatically: - Collect real user performance metrics - Send data to Vercel's Speed Insights dashboard - Track Core Web Vitals (LCP, FID, CLS, FCP, TTFB, INP) ### Verification: - ✅ Build completed successfully with no errors - ✅ All dependencies installed correctly - ✅ Lock file (package-lock.json) updated - ✅ Code follows existing project patterns and conventions - ✅ Component properly placed within the React component tree The Speed Insights integration is now complete and will begin collecting metrics once deployed to Vercel. Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
1 parent a8b2be7 commit a2f06f7

4 files changed

Lines changed: 40 additions & 2 deletions

File tree

next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
import "./.next/dev/types/routes.d.ts";
3+
import "./.next/types/routes.d.ts";
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.

package-lock.json

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@microlink/mql": "^0.14.0",
1717
"@mui/icons-material": "^7.3.7",
1818
"@mui/material": "^7.3.7",
19+
"@vercel/speed-insights": "^1.3.1",
1920
"moment": "^2.29.4",
2021
"next": "16.1.6",
2122
"prop-types": "^15.7.2",

pages/_app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import '../styles/app.css'
55
import {useEffect} from "react";
66
import { ThemeProvider } from '@mui/material/styles';
77
import theme from '../utils/theme';
8+
import { SpeedInsights } from '@vercel/speed-insights/next';
89

910
export default function MyApp(props) {
1011
const { Component, pageProps } = props;
@@ -34,6 +35,7 @@ export default function MyApp(props) {
3435
<Layout>
3536
<Component {...pageProps} />
3637
</Layout>
38+
<SpeedInsights />
3739
</ThemeProvider>
3840
);
39-
}
41+
}

0 commit comments

Comments
 (0)