Commit 5595d1f
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
0 commit comments