Skip to content

Commit 5595d1f

Browse files
authored
Install Vercel Speed Insights for Next.js (#257)
## Vercel Speed Insights Implementation Successfully installed and configured Vercel Speed Insights for this Next.js 16.0.7 project with App Router. ### Changes Made: **1. Package Installation:** - Installed `@vercel/speed-insights@1.3.1` using npm - Updated `package.json` to include the new dependency - Updated `package-lock.json` with resolved dependencies **2. Root Layout Integration (frontend/app/layout.tsx):** - Added import: `import { SpeedInsights } from '@vercel/speed-insights/next'` - Added `<SpeedInsights />` component inside the `<body>` tag, after the `{children}` element - This follows the recommended approach for Next.js 13.5+ with App Router ### Implementation Details: The project uses: - Next.js 16.0.7 (App Router architecture) - npm as package manager - Root layout at `frontend/app/layout.tsx` Since Next.js 16 is well above version 13.5, I used the simplified App Router approach: - Imported from `@vercel/speed-insights/next` (not `/react`) - No need for 'use client' directive or usePathname() hook - Component automatically handles route tracking The SpeedInsights component is placed at the root layout level, ensuring it runs on all pages of the application. It's positioned after {children} in the body tag, following best practices for performance monitoring tools. ### Files Modified: - `frontend/app/layout.tsx` - Added SpeedInsights import and component - `frontend/package.json` - Added @vercel/speed-insights dependency - `frontend/package-lock.json` - Updated lock file with new dependency tree ### Verification: - ✓ Package successfully installed - ✓ Linter ran without introducing new errors - ✓ TypeScript types are correct - ✓ Code follows existing project patterns - ✓ Lock file updated correctly The implementation is complete and ready for deployment. Speed Insights will automatically start collecting performance metrics when the application is deployed to Vercel. Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
1 parent 3f1b34c commit 5595d1f

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

frontend/app/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Metadata } from 'next';
22
import { Geist, Geist_Mono } from 'next/font/google';
3+
import { SpeedInsights } from '@vercel/speed-insights/next';
34
import './globals.css';
45

56
export const metadata: Metadata = {
@@ -58,6 +59,7 @@ export default function RootLayout({
5859
className={`${geistSans.variable} ${geistMono.variable} antialiased bg-gray-50 text-gray-900 dark:bg-neutral-950 dark:text-gray-100 transition-colors duration-300`}
5960
>
6061
{children}
62+
<SpeedInsights />
6163
</body>
6264
</html>
6365
);

frontend/package-lock.json

Lines changed: 37 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@stripe/stripe-js": "^8.6.0",
3333
"@upstash/redis": "^1.36.1",
3434
"@vercel/analytics": "^1.6.1",
35+
"@vercel/speed-insights": "^1.3.1",
3536
"bcryptjs": "^3.0.3",
3637
"class-variance-authority": "^0.7.1",
3738
"cloudinary": "^2.8.0",

0 commit comments

Comments
 (0)