Docs
Install and configure Bundle Cop to optimize Next.js bundle size on Vercel — budgets, attribution, and deploy reports.
Install the adapter
Requires Next.js 16+. Package: bundle-cop-vercel-plugin.
pnpm add bundle-cop-vercel-plugin
Point Next.js at the adapter in next.config.ts:
import type { NextConfig } from 'next'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const nextConfig: NextConfig = {
adapterPath: require.resolve('bundle-cop-vercel-plugin/adapter'),
}
export default nextConfigAfter next build, inspect bundle-report.json in the project root.
Budgets config
Optional. Copy bundle-cop.config.example.json to bundle-cop.config.json:
{
"budgets": [
{ "path": "/*", "maxSize": "250kb", "enforce": "warn" },
{ "path": "/dashboard", "maxSize": "400kb", "enforce": "error" }
],
"ignore": ["node_modules/**/locales/**"],
"githubComment": true,
"suggestions": true
}enforce: "warn"— log onlyenforce: "error"— fail the build when over budgetsuggestions— suggest lighter alternatives (e.g. date-fns for moment)
Prove it locally
The monorepo example/ app imports moment so you can verify attribution:
pnpm install pnpm build:plugin pnpm --filter @bundle-cop/example build # → example/bundle-report.json (moment → app/page.tsx)
Integration app
This site (bundle-cop.vercel.app) hosts setup, dashboard, and webhooks for the Vercel integration.
| Route | Purpose |
|---|---|
| / | Product landing |
| /docs | Full documentation (this page) |
| /setup | Default budgets / fail-on-over-budget guidance |
| /dashboard | Bundle history from private Blob reports |
POST /api/webhooks/vercel | Deployment webhook → Checks |
GET /api/reports/[sha] | Fetch a report by commit SHA |
| /privacy | Privacy Policy |
| /eula | End User License Agreement |
Environment variables
| Variable | Required | Purpose |
|---|---|---|
BLOB_READ_WRITE_TOKEN | Blob / installs | Private Blob for reports + OAuth install tokens |
INTEGRATION_CLIENT_ID | Marketplace install | OAuth client ID from Integrations Console |
INTEGRATION_CLIENT_SECRET | Marketplace install | OAuth client secret |
VERCEL_WEBHOOK_SECRET | Webhooks | Verify Vercel webhook signatures |
VERCEL_TOKEN | Optional fallback | Personal/team token for Checks when no OAuth install token exists. Create at vercel.com/account/tokens, then set on the Bundle Cop project. |
GITHUB_APP_* | Optional | GitHub Check Runs |
Publishing
npm releases ship from GitHub Releases. Tag vX.Y.Z → CI publishes bundle-cop-vercel-plugin.
- Ensure repo secret
NPM_TOKENis set - Create a GitHub Release with tag
vX.Y.Z - Actions bumps version and runs
npm publish