pagelens-next
v0.1.1
Published
See which AI crawlers and assistants (GPTBot, ClaudeBot, ChatGPT-User, PerplexityBot) read your Next.js site — PageLens AI Visibility in one line of middleware.
Maintainers
Readme
pagelens-next
See which AI crawlers and assistants read your Next.js site — GPTBot, ClaudeBot, ChatGPT-User, PerplexityBot and more — in PageLens AI Visibility.
AI bots download your HTML without running JavaScript, so no analytics script can see them. This middleware reports their requests to PageLens in the background. Human visitors are never sent, and responses are never delayed.
Install
npm install pagelens-nextCreate middleware.ts in your project root (next to app/ or pages/):
import { pagelens } from 'pagelens-next';
export const middleware = pagelens('YOUR_SITE_ID');Next.js 16: the file is called proxy.ts and the export proxy:
import { pagelens } from 'pagelens-next';
export const proxy = pagelens('YOUR_SITE_ID');Your site ID is in PageLens → Site Settings. Deploy, then open AI Visibility → Check connection.
Already have a middleware?
Wrap it — it keeps working exactly as before:
import { pagelens } from 'pagelens-next';
import { myMiddleware } from './my-middleware';
export const middleware = pagelens('YOUR_SITE_ID', myMiddleware);What is sent
For requests whose user agent looks like a bot: the site ID, the user agent, the path (no query string) and the client IP, which is used only to look up the country and is never stored. Static files, /_next/ and /api/ routes are skipped.
License
MIT
