{"_id":"@aeolens/middleware","_rev":"4-8690675d85b887cfa9b15b75f31b2018","name":"@aeolens/middleware","dist-tags":{"latest":"0.3.3"},"versions":{"0.3.0":{"name":"@aeolens/middleware","version":"0.3.0","keywords":["aeolens","next.js","middleware","ai","crawler","analytics","gpt","claude","perplexity"],"author":{"name":"aeolens"},"license":"MIT","_id":"@aeolens/middleware@0.3.0","maintainers":[{"name":"nexlr","email":"contact@nexlr.in"}],"homepage":"https://aeolens.ai/docs","bugs":{"url":"https://github.com/aeolens/aeolens/issues"},"bin":{"middleware":"dist/cli.cjs","aeolens-middleware":"dist/cli.cjs"},"dist":{"shasum":"41e7fe4cd391c8a6d0f412571302e6c52152ae8d","tarball":"https://registry.npmjs.org/@aeolens/middleware/-/middleware-0.3.0.tgz","fileCount":11,"integrity":"sha512-1mMllvgzebgy0ef7fG9KXHwJVS+Aa71QH/YvV9FJwBonKYJ9dZ4c3Z7rNp76ZT2999pBUBAxQZjvB+XOvcdQ0Q==","signatures":[{"sig":"MEUCIB1TOzR3mZ8r8RMQXZG8wa50jBcuKBVY4pwtQ/DDnCWWAiEAwx1vIcw0iW0KqD+6ce/xUtdLGriq2nbz5ogjlzQBZ3E=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27964},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsup src/index.ts src/cli.ts --format esm,cjs --dts --clean --external next","build:ci":"tsup src/index.ts src/cli.ts --format esm,cjs --dts --external next","typecheck":"tsc --noEmit"},"_npmUser":{"name":"nexlr","email":"contact@nexlr.in"},"repository":{"url":"git+https://github.com/aeolens/aeolens.git","type":"git","directory":"packages/aeolens-next"},"_npmVersion":"10.9.3","description":"Zero-latency AI crawler tracking for Next.js — AEOlens middleware integration","directories":{},"_nodeVersion":"22.19.0","_hasShrinkwrap":false,"devDependencies":{"next":"^14.0.0","tsup":"^8.0.0","typescript":"^5.0.0","@types/node":"^20.0.0"},"peerDependencies":{"next":">=13.0.0"},"peerDependenciesMeta":{"next":{"optional":false}},"_npmOperationalInternal":{"tmp":"tmp/middleware_0.3.0_1781412171859_0.11539081580927824","host":"s3://npm-registry-packages-npm-production"}},"0.3.1":{"name":"@aeolens/middleware","version":"0.3.1","keywords":["aeolens","next.js","middleware","ai","crawler","analytics","gpt","claude","perplexity"],"author":{"name":"aeolens"},"license":"MIT","_id":"@aeolens/middleware@0.3.1","maintainers":[{"name":"nexlr","email":"contact@nexlr.in"}],"homepage":"https://aeolens.ai/docs","bugs":{"url":"https://github.com/aeolens/aeolens/issues"},"bin":{"middleware":"dist/cli.cjs","aeolens-middleware":"dist/cli.cjs"},"dist":{"shasum":"01deea26d23aaa45d556c8ccceaf958cb7dca3ba","tarball":"https://registry.npmjs.org/@aeolens/middleware/-/middleware-0.3.1.tgz","fileCount":11,"integrity":"sha512-eO41RVIwLqADyGYYA8lsgCQQax7ZAVILsaFEUMPVjjCELoyXu2ZqIjXkzQqCNAsEPDa0p1kIpJmdc0jIw4m44g==","signatures":[{"sig":"MEUCIAvVVfS9u9WDp+vgYd0uk9Gv8oO7uRAQGvLBU/5JUKgIAiEAjcGl8UqhcqOcGVhExeDF1zTyLVmnIHZvO0IghW73XPI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27696},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsup src/index.ts src/cli.ts --format esm,cjs --dts --clean --external next","build:ci":"tsup src/index.ts src/cli.ts --format esm,cjs --dts --external next","typecheck":"tsc --noEmit"},"_npmUser":{"name":"nexlr","email":"contact@nexlr.in"},"repository":{"url":"git+https://github.com/aeolens/aeolens.git","type":"git","directory":"packages/aeolens-next"},"_npmVersion":"10.9.3","description":"Zero-latency AI crawler tracking for Next.js — AEOlens middleware integration","directories":{},"_nodeVersion":"22.19.0","_hasShrinkwrap":false,"devDependencies":{"next":"^14.0.0","tsup":"^8.0.0","typescript":"^5.0.0","@types/node":"^20.0.0"},"peerDependencies":{"next":">=13.0.0"},"peerDependenciesMeta":{"next":{"optional":false}},"_npmOperationalInternal":{"tmp":"tmp/middleware_0.3.1_1781412932870_0.6513210403697751","host":"s3://npm-registry-packages-npm-production"}},"0.3.2":{"name":"@aeolens/middleware","version":"0.3.2","keywords":["aeolens","next.js","middleware","ai","crawler","analytics","gpt","claude","perplexity"],"author":{"name":"aeolens"},"license":"MIT","_id":"@aeolens/middleware@0.3.2","maintainers":[{"name":"nexlr","email":"contact@nexlr.in"}],"homepage":"https://aeolens.ai/docs","bugs":{"url":"https://github.com/aeolens/aeolens/issues"},"bin":{"middleware":"dist/cli.cjs","aeolens-middleware":"dist/cli.cjs"},"dist":{"shasum":"94f8b15dcc364ef7cce5f30eee4fd365ca5fa669","tarball":"https://registry.npmjs.org/@aeolens/middleware/-/middleware-0.3.2.tgz","fileCount":11,"integrity":"sha512-XMxK7yioJm0Ber1TafeDRrxpzRWWUPePF67jQu5pSXx8rTF9SumP2cbZsQ03mD+Z20RX73Rxf6Ysuj11sY/DPg==","signatures":[{"sig":"MEUCICLTBprEIiiGZhhQvqc1XAQaaJbDQBweLFUyayAcYA9GAiEAlbCwO4bphEOwSbhirtX6Zhqr926kCCoGrXuvpOVlTDc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30033},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsup src/index.ts src/cli.ts --format esm,cjs --dts --clean --external next","build:ci":"tsup src/index.ts src/cli.ts --format esm,cjs --dts --external next","typecheck":"tsc --noEmit"},"_npmUser":{"name":"nexlr","email":"contact@nexlr.in"},"repository":{"url":"git+https://github.com/aeolens/aeolens.git","type":"git","directory":"packages/aeolens-next"},"_npmVersion":"10.9.3","description":"Zero-latency AI crawler tracking for Next.js — AEOlens middleware integration","directories":{},"_nodeVersion":"22.19.0","_hasShrinkwrap":false,"devDependencies":{"next":"^14.0.0","tsup":"^8.0.0","typescript":"^5.0.0","@types/node":"^20.0.0"},"peerDependencies":{"next":">=13.0.0"},"peerDependenciesMeta":{"next":{"optional":false}},"_npmOperationalInternal":{"tmp":"tmp/middleware_0.3.2_1781414573479_0.7931558680228439","host":"s3://npm-registry-packages-npm-production"}},"0.3.3":{"name":"@aeolens/middleware","version":"0.3.3","description":"Zero-latency AI crawler tracking for Next.js — AEOlens middleware integration","keywords":["aeolens","next.js","middleware","ai","crawler","analytics","gpt","claude","perplexity"],"homepage":"https://aeolens.ai/docs","repository":{"type":"git","url":"git+https://github.com/aeolens/aeolens.git","directory":"packages/aeolens-next"},"bugs":{"url":"https://github.com/aeolens/aeolens/issues"},"author":{"name":"aeolens"},"license":"MIT","type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"bin":{"aeolens-middleware":"dist/cli.cjs","middleware":"dist/cli.cjs"},"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"tsup src/index.ts src/cli.ts --format esm,cjs --dts --clean --external next","build:ci":"tsup src/index.ts src/cli.ts --format esm,cjs --dts --external next","typecheck":"tsc --noEmit"},"peerDependencies":{"next":">=13.0.0"},"peerDependenciesMeta":{"next":{"optional":false}},"engines":{"node":">=18"},"devDependencies":{"@types/node":"^20.0.0","next":"^14.0.0","tsup":"^8.0.0","typescript":"^5.0.0"},"_id":"@aeolens/middleware@0.3.3","_nodeVersion":"22.19.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-KiTMCMmIt9+0ugQ+ItrGbGH1ao2f1qvxkSR6UEv/KgoFDcd/aRo9UbfWbPFHIuvg7EDY7CUONR97VOdTD2Dtvw==","shasum":"679aa324e2ae8249b7a4fed01cabebdc6a31a7d9","tarball":"https://registry.npmjs.org/@aeolens/middleware/-/middleware-0.3.3.tgz","fileCount":11,"unpackedSize":30623,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBMfKVdq1rg9NCQcS2Q6wtJ/K4REn5JwwF2YYKh/Oh0GAiA3RtrDn7CYMbYt8cIg76m7DUUStS3gLrCTAt0YHjJCvg=="}]},"_npmUser":{"name":"nexlr","email":"contact@nexlr.in"},"directories":{},"maintainers":[{"name":"nexlr","email":"contact@nexlr.in"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/middleware_0.3.3_1781788475146_0.4267655513817399"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-14T04:42:51.695Z","modified":"2026-06-18T13:14:35.402Z","0.3.0":"2026-06-14T04:42:52.008Z","0.3.1":"2026-06-14T04:55:33.035Z","0.3.2":"2026-06-14T05:22:53.603Z","0.3.3":"2026-06-18T13:14:35.285Z"},"bugs":{"url":"https://github.com/aeolens/aeolens/issues"},"author":{"name":"aeolens"},"license":"MIT","homepage":"https://aeolens.ai/docs","keywords":["aeolens","next.js","middleware","ai","crawler","analytics","gpt","claude","perplexity"],"repository":{"type":"git","url":"git+https://github.com/aeolens/aeolens.git","directory":"packages/aeolens-next"},"description":"Zero-latency AI crawler tracking for Next.js — AEOlens middleware integration","maintainers":[{"name":"nexlr","email":"contact@nexlr.in"}],"readme":"# @aeolens/middleware\n\nZero-latency AI crawler tracking for Next.js. Detects visits from GPT, Claude, Perplexity, Gemini, and 20+ other AI crawlers and reports them to [AEOlens](https://aeolens.ai) — without adding any latency to your site.\n\n## How it works\n\nThe proxy runs on the server, checks the `User-Agent` header on every request, and fires a fire-and-forget beacon to AEOlens if an AI crawler is detected. Your users never wait for the beacon — it runs in the background after the response is sent.\n\n## Quick start\n\n```bash\nnpx @aeolens/middleware init\n```\n\nThat's it. The CLI creates `proxy.ts` (or `middleware.ts` for Next.js < 16) and writes your API key to `.env.local`. Deploy and AI crawler visits appear in your [AEOlens dashboard](https://aeolens.ai/agent-analytics).\n\nGet your API key from [AEOlens → Settings → Integrations](https://aeolens.ai/settings/integrations).\n\nNeed to change your API key? Run:\n\n```bash\nnpx @aeolens/middleware init --reset-key\n```\n\n## Manual setup\n\nIf you prefer to set things up yourself:\n\n```bash\nnpm install @aeolens/middleware\n```\n\n**1. Add your API key to `.env.local`:**\n\n```bash\nAEOLENS_KEY=aa_your_key_here\n```\n\n**2. Create `proxy.ts` in your project root (Next.js 16+):**\n\n```ts\nimport { withAEOlens } from '@aeolens/middleware'\n\nexport const proxy = withAEOlens()\n\nexport const config = {\n  matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],\n}\n```\n\n> For Next.js 13–15, use `middleware.ts` with `export const middleware = withAEOlens()` instead.\n\n## Composing with existing proxy\n\nIf you already have a `proxy.ts`, call `withAEOlens()` alongside your existing logic:\n\n```ts\nimport { withAEOlens } from '@aeolens/middleware'\nimport { auth } from './lib/auth'\nimport type { NextRequest } from 'next/server'\n\nconst tracking = withAEOlens()\n\nexport async function proxy(req: NextRequest) {\n  // Tracking runs first — non-blocking, never delays auth\n  await tracking(req)\n  return auth(req)\n}\n\nexport const config = {\n  matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],\n}\n```\n\n## Options\n\n```ts\nwithAEOlens({\n  // Explicit key — overrides AEOLENS_KEY env var\n  key: 'aa_your_key_here',\n\n  // Called when a bot is detected. Return false to skip the beacon.\n  onDetect({ bot, url, userAgent }) {\n    console.log(`${bot} visited ${url}`)\n    // return false  ← suppress beacon for this request\n  },\n})\n```\n\n## Detected crawlers\n\nGPTBot · ChatGPT-User · OAI-SearchBot · ClaudeBot · Claude-Web · anthropic-ai · PerplexityBot · Googlebot · Google-Extended · bingbot · Bytespider · DuckAssistBot · CCBot · Amazonbot · Applebot · cohere-ai · meta-externalagent · LinkedInBot · Twitterbot · and more.\n\nThe list is kept in sync with the AEOlens backend. You can also export `KNOWN_AI_BOTS` and `detectBot` from this package if you need them elsewhere.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}