Commit 0400f7d
committed
Install Vercel Web Analytics in Next.js
Implemented Vercel Web Analytics for Next.js App Router
## Summary
Successfully installed and configured @vercel/analytics for the Coffee Timer Next.js application which uses the App Router architecture with internationalization (i18n).
## Changes Made
### 1. Package Installation
- Installed `@vercel/analytics` version 1.6.1 using pnpm
- Updated `package.json` to include the new dependency
- Updated `pnpm-lock.yaml` with the new package and its dependencies
### 2. Analytics Integration
Modified: `app/[locale]/layout.tsx`
- Added import statement: `import { Analytics } from '@vercel/analytics/next'`
- Added `<Analytics />` component inside the `<body>` tag, after the `<LayoutBody>` component and `{children}`
## Implementation Details
The project uses Next.js App Router with a locale-based routing structure. The main layout is located at `app/[locale]/layout.tsx` rather than the root `app/layout.tsx` (which is minimal due to the locale segment).
The Analytics component was placed inside the body tag to ensure it's included on all pages across all locale routes. This placement follows Vercel's best practices for App Router implementations.
## Verification
✅ Build: Successfully compiled with `pnpm run build`
✅ TypeScript: Passed type checking with `pnpm run typecheck`
✅ Linting: Passed ESLint checks with `pnpm run lint --max-warnings=0`
✅ Dependencies: Lock file properly updated
## Files Modified
- `app/[locale]/layout.tsx` - Added Analytics import and component
- `package.json` - Added @vercel/analytics dependency
- `pnpm-lock.yaml` - Updated with new package dependencies
The implementation is complete and ready for deployment. The Analytics component will automatically track page views and Web Vitals when deployed to Vercel.
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>1 parent 0ab72ef commit 0400f7d
3 files changed
+37
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
| 155 | + | |
154 | 156 | | |
155 | 157 | | |
156 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments