From ade89c80ce67e48aa6ec67cc423a9cac54b44b38 Mon Sep 17 00:00:00 2001
From: Vercel
Date: Sat, 4 Jul 2026 00:17:49 +0000
Subject: [PATCH] Add Vercel Web Analytics integration
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Implemented Vercel Web Analytics for the pi-package-index project.
## Changes Made:
### 1. Installed @vercel/analytics package
- Added `@vercel/analytics` version 2.0.1 to project dependencies
- Used pnpm (project's package manager) to install the package
### 2. Modified src/app/layout.tsx
- Imported the Analytics component from '@vercel/analytics/next'
- Added the component inside the tag before the closing tag
- Followed Next.js App Router pattern as per official Vercel documentation
### 3. Updated lock files
- pnpm-lock.yaml was automatically updated during package installation
## Implementation Details:
The implementation follows the official Vercel Analytics quickstart guide (fetched from https://vercel.com/docs/analytics/quickstart) for Next.js App Router applications:
1. Package installed: `@vercel/analytics@^2.0.1`
2. Import added: `import { Analytics } from '@vercel/analytics/next';`
3. Component placed at the end of the root layout's tag for optimal performance
## Verification:
- ✅ Build completed successfully with no errors
- ✅ TypeScript compilation passed
- ✅ ESLint linting passed with no issues
- ✅ All existing code structure preserved
- ✅ Lock files properly updated
## Files Modified:
- package.json - Added @vercel/analytics dependency
- pnpm-lock.yaml - Updated with new package and dependencies
- src/app/layout.tsx - Added Analytics component import and usage
## Next Steps (Manual):
To complete the setup, you'll need to:
1. Enable Web Analytics in your Vercel dashboard (Analytics section)
2. Deploy the changes to Vercel
3. Verify analytics are working by checking the Network tab for requests to `//view`
Co-authored-by: Vercel
---
package.json | 1 +
pnpm-lock.yaml | 37 +++++++++++++++++++++++++++++++++++++
src/app/layout.tsx | 2 ++
3 files changed, 40 insertions(+)
diff --git a/package.json b/package.json
index 96639dd..217ceff 100644
--- a/package.json
+++ b/package.json
@@ -26,6 +26,7 @@
]
},
"dependencies": {
+ "@vercel/analytics": "^2.0.1",
"flexsearch": "^0.8.212",
"lucide-react": "^1.21.0",
"next": "^16.2.9",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e0a8475..d5a4445 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -8,6 +8,9 @@ importers:
.:
dependencies:
+ '@vercel/analytics':
+ specifier: ^2.0.1
+ version: 2.0.1(next@16.2.9(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7))(react@19.2.7)
flexsearch:
specifier: ^0.8.212
version: 0.8.212
@@ -944,6 +947,35 @@ packages:
cpu: [x64]
os: [win32]
+ '@vercel/analytics@2.0.1':
+ resolution: {integrity: sha512-MTQG6V9qQrt1tsDeF+2Uoo5aPjqbVPys1xvnIftXSJYG2SrwXRHnqEvVoYID7BTruDz4lCd2Z7rM1BdkUehk2g==}
+ peerDependencies:
+ '@remix-run/react': ^2
+ '@sveltejs/kit': ^1 || ^2
+ next: '>= 13'
+ nuxt: '>= 3'
+ react: ^18 || ^19 || ^19.0.0-rc
+ svelte: '>= 4'
+ vue: ^3
+ vue-router: ^4
+ peerDependenciesMeta:
+ '@remix-run/react':
+ optional: true
+ '@sveltejs/kit':
+ optional: true
+ next:
+ optional: true
+ nuxt:
+ optional: true
+ react:
+ optional: true
+ svelte:
+ optional: true
+ vue:
+ optional: true
+ vue-router:
+ optional: true
+
acorn-jsx@5.3.2:
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
peerDependencies:
@@ -3263,6 +3295,11 @@ snapshots:
'@unrs/resolver-binding-win32-x64-msvc@1.12.2':
optional: true
+ '@vercel/analytics@2.0.1(next@16.2.9(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7))(react@19.2.7)':
+ optionalDependencies:
+ next: 16.2.9(@babel/core@7.29.7)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)
+ react: 19.2.7
+
acorn-jsx@5.3.2(acorn@8.17.0):
dependencies:
acorn: 8.17.0
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index 9deda09..8734f4b 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -2,6 +2,7 @@ import "./globals.css";
import type { Metadata } from "next";
import Link from "next/link";
import { GithubIcon } from "@/components/GithubIcon";
+import { Analytics } from "@vercel/analytics/next";
export const metadata: Metadata = {
title: "Pi Package Index — unofficial community index",
@@ -73,6 +74,7 @@ export default function RootLayout({
+
);