Add Vercel Web Analytics to Next.js #28
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Vercel Web Analytics Installation Report
Summary
Successfully installed and configured Vercel Web Analytics for the Next.js App Router project.
Changes Made
1. Installed @vercel/analytics Package
@vercel/analytics@1.6.1to dependencies using Bun package managerbun add @vercel/analytics2. Modified Files
apps/web/app/layout.tsximport { Analytics } from '@vercel/analytics/next';at the top of the file<Analytics />component inside the<body>tag, after the ThemeProvider closing tagapps/web/package.json@vercel/analyticsas a new dependencybun.lockImplementation Details
The Analytics component was added to the root layout file (
apps/web/app/layout.tsx) which is the standard approach for App Router projects. This ensures that analytics tracking is available across all pages of the application.The component placement inside the
<body>tag ensures it loads after the main content but is still part of the initial page render, allowing it to capture page views and web vitals data effectively.Verification Steps Completed
bun run typecheck- Passed with no errorsbun run lint app/layout.tsx- No errors in the modified fileNotes
View Project · Web Analytics
Created by yashdev9274 with Vercel Agent