Classic search bots (Googlebot, Bingbot, Applebot) always receive your normal page.
Google’s AI Overviews use the same crawl as Google Search, so serving them anything else
would be cloaking Search itself.
Prerequisites
You need a Next.js project already deployed on Vercel and a
Bluemoon account with at least one domain connected.
No other dependencies or build-step changes are required.
Setup
1
Get your edge token in Agent Analytics
- Open app.trybluemoon.com and go to Agent Analytics.
- Select your domain, choose Next.js / Vercel, then click Connect edge.
- Copy the edge token that appears. It is shown once. If you lose it, open Setup in Agent Analytics and click Regenerate to get a new one (the old one stops working immediately).
2
Add AEN_EDGE_TOKEN to Vercel
In the Vercel dashboard, go to your project → Settings →
Environment Variables and add:Replace the placeholder with the token from Step 1. Enable it for Production (and
Preview if you want to test on preview deployments). If the variable is missing or
empty, the middleware lets every request through untouched and records nothing.
3
Install the middleware at the project root
Follow the Next.js Middleware guide: run
Commit and push to trigger a Vercel deployment.
npx @trybluemoon/aen init, or copy the self-contained middleware.ts, and place it at
the root of your Next.js project (the same level as package.json).The copy-paste file has zero dependencies and runs on the Vercel Edge runtime.
Two parts of it are yours to change:The middleware ships in shadow mode. It logs every AI crawler visit but always
serves your normal page, so it is safe to deploy to production immediately — no visitor
ever sees a different response.
4
Test with a browsing AI
Once your deployment is live, trigger a real AI crawler:
- Open ChatGPT (with browsing) or Perplexity (web search on). ChatGPT is the most reliable first test: its visits can be verified.
- Ask something that makes it look up a page on your domain — e.g. “What does [your-domain.com] say about X?”
- The crawler fetches your page. If Bluemoon can confirm the crawler comes from the AI
company it claims, the visit is recorded as Verified (
IP_VERIFIED); if it recognises the crawler but cannot confirm it, the visit is recorded as Unverified (UA_ONLY). Only verified visits can ever receive the optimized version. - Open Agent Analytics. The visit should appear shortly under Recent activity, marked Verified or Unverified, and counted under Why they came.
If nothing appears, confirm that
AEN_EDGE_TOKEN is set in Vercel, that the
deployment containing middleware.ts is the active one, and that the AI tool
actually fetched a page (some prompts trigger a web search but not a page visit).
See Troubleshooting.5
Go live — switch the serve mode to default
Once you’ve seen verified visits in Agent Analytics and you’re ready for AI crawlers
to receive the optimized pages, switch the serve mode.With the copy-paste file, change the constant:With the npm package, set
AEN_SERVE_MODE=default in your Vercel environment variables.Redeploy. From then on, a crawler receives the optimized version only when all of
these hold: it is verified (IP_VERIFIED), its purpose is USER_TRIGGERED or
RETRIEVAL, and an optimized version exists for that URL. Everyone else — humans,
search bots and unverified crawlers — keeps getting your normal page.Serve modes
The Next.js middleware supports two modes:
See Serve modes for how to roll out safely.
What’s next
Agent Analytics
AI requests, the crawlers that visit you and why, what each visit received, and how
many of the pages served to AI were later cited.
Optimized pages
What AI crawlers receive, and how to check and regenerate each page’s optimized version.