Next.js
Track AI agents in your Next.js app
One line in middleware.ts. Works on any host, in Edge or Node, and only agent requests cost you anything.
Why you can't see them today
Your analytics is a client component. An agent fetches the server-rendered HTML and leaves — no hydration, no JavaScript, no event. The request is in your logs and nowhere in your dashboard.
The reason there's no script tag to paste. AI agents don't execute JavaScript. Every analytics tool you already run is a browser tag, so it never fires for an agent — which is why your dashboards show none of this traffic. The only way to see it is server-side, at the edge, or in your logs.
See yours before you install anything
Check my log free →Install: Middleware
- Install the collector. It's dependency-free and MIT licensed.
npm i @pickrate/collector - Re-export the middleware. If you don't have a middleware.ts yet, this is the whole file.
// middleware.ts export { middleware } from "@pickrate/collector/next"; export const config = { matcher: ["/((?!_next|favicon).*)"] }; - Set your key. Add PICKRATE_KEY to your environment with a secret (sk_) key from Pickrate Settings. With no key set, the collector is a no-op — your app behaves identically.
Gotchas worth knowing first
Middleware can't see response status
It must be a secret key, not a publishable one
Already composing your own middleware?
Questions
Does this slow down my app?
Does it work on the Edge runtime?
What if I'm not on Vercel?
Other setups
- See which AI agents crawl your Vercel site — Zero code. Covers every framework on Vercel at once, and captures response status.
- Track AI agent traffic with a Cloudflare Worker — Goes in front of any origin. The only option when you don't control the codebase.
- All install options — the full chooser, including pasting a log with no install at all.
- Developer reference — every method in one place.