Vercel Middleware

Install SeeLLM on Vercel or Next.js with the official @seellm/vercel-middleware package.

Use the Vercel middleware integration when your homepage, pricing, docs, comparison pages, or programmatic SEO pages run on Next.js and deploy through Vercel.

The middleware runs before your route renders, captures server-side request evidence, and sends signed events to SeeLLM without adding browser JavaScript.

Requirements

  • A Next.js project deployed on Vercel
  • Access to edit middleware.ts or add one at the project root
  • A SeeLLM account with an org and site monitor setup access
  • Vercel project permission to add environment variables

1. Install the package

pnpm add @seellm/vercel-middleware

npm and yarn work too:

npm install @seellm/vercel-middleware
# or
yarn add @seellm/vercel-middleware

2. Add middleware

Create or update middleware.ts in your Next.js project:

import { withSeeLLM } from '@seellm/vercel-middleware';

export default withSeeLLM();

export const config = {
  matcher: ['/((?!_next/static|_next/image|favicon.ico|robots.txt|sitemap.xml).*)'],
};

The matcher excludes common static assets while keeping public pages, docs, pricing pages, comparison pages, and programmatic SEO pages visible to SeeLLM.

3. Wrap existing middleware

If your project already uses middleware for auth, localization, routing, or experiments, wrap it instead of replacing it:

import { NextResponse } from 'next/server';
import { withSeeLLM } from '@seellm/vercel-middleware';

function existingMiddleware(request: Request) {
  // Keep your current middleware logic here.
  return NextResponse.next();
}

export default withSeeLLM({
  middleware: existingMiddleware,
});

4. Generate credentials

In SeeLLM, open Site Monitor -> Setup -> Vercel / Next.js and generate Vercel credentials.

Add the generated values to your Vercel project environment variables:

SEELLM_ADAPTER_ID=adapter_...
SEELLM_ADAPTER_SECRET=...
SEELLM_ORG_ID=org_...
SEELLM_SITE_DOMAIN=example.com
SEELLM_API_URL=https://api.seellm.link

Do not expose SEELLM_ADAPTER_SECRET in client-side code. It should only be available to Vercel middleware.

5. Deploy and verify

Deploy your Vercel project, then request one or two public pages such as:

  • /
  • /pricing
  • /docs
  • /compare/...

Return to Site Monitor -> Setup in SeeLLM and check for adapter activity. SeeLLM classifies AI crawler and AI referral evidence after ingestion.

What SeeLLM captures

  • Page path and query string
  • Request method
  • User-agent
  • Accept header
  • Referrer
  • Vercel geo headers when available
  • Forwarded IP when available
  • Vercel request ID
  • Adapter runtime: vercel_edge

Cloudflare versus Vercel

Cloudflare Worker installs provide richer edge metadata, including Cloudflare-specific ASN and cache details. Vercel middleware is the fastest path for Next.js teams that want to validate page-level AI crawler and referral monitoring without changing CDN providers.

Troubleshooting

SymptomCheck
No activity in SeeLLMConfirm middleware.ts deployed and the matcher includes the page you visited.
401 or rejected eventsRegenerate credentials in SeeLLM and update Vercel env vars.
Only some pages appearReview the matcher and any rewrites or auth middleware that returns before SeeLLM runs.
Secret missing after deployConfirm env vars are set for the correct Vercel environment: Production, Preview, or Development.

Next steps