@agent-seo/next
v1.0.3
Published
Next.js plugin for AI-readable websites
Maintainers
Readme
@agent-seo/next
Next.js plugin for AI-readable websites. Zero-config /llms.txt, automatic HTML-to-Markdown for AI bots.
Install
npm install @agent-seo/nextQuick Start
next.config.ts — wrap your config:
import { withAgentSeo } from '@agent-seo/next';
export default withAgentSeo({
siteName: 'My App',
siteDescription: 'A brief description for AI systems.',
baseUrl: 'https://myapp.com',
sitemap: true,
})({
// your existing Next.js config
});middleware.ts — enable AI bot detection:
import { createAgentSeoMiddleware } from '@agent-seo/next/middleware';
export default createAgentSeoMiddleware({
exclude: ['/dashboard/**', '/admin/**'],
});
export const config = {
matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
};That's it. Two files, ~10 lines total.
What It Does Automatically
- Auto-generates
/llms.txtby scanning yourapp/directory and extractingmetadata(title, description) - Auto-generates a transform API route that converts HTML to Markdown on the fly
- Auto-generates
robots.txtwith an AI-friendly config pointing to/llms.txt - Detects 19 AI bots via User-Agent and rewrites their requests to serve Markdown
- Handles
.mdsuffix requests (e.g.,/about.mdreturns Markdown) - Injects
Vary: Accept, User-Agentheaders for correct CDN caching - Sets bot-friendly headers —
Content-Disposition: inline,X-Robots-Tag: all
How It Works
Browser → GET /about → HTML (normal)
GPTBot → GET /about → Markdown (automatic)
Anyone → GET /about.md → Markdown (explicit)
Anyone → GET /llms.txt → Site directory for AI agentsPlugin Options
| Option | Type | Description |
| ----------------- | ------------------- | ----------------------------------------------------------------------------------------- |
| siteName | string | Your site name (used in llms.txt) |
| siteDescription | string | Brief description for AI systems |
| baseUrl | string | Your site's public URL |
| sitemap | boolean \| string | Add Sitemap: to robots.txt. true uses {baseUrl}/sitemap.xml, or pass a custom URL |
| appDir | string | Override auto-detected app/ directory path |
| exclude | string[] | Route patterns to exclude from llms.txt discovery |
Middleware Options
createAgentSeoMiddleware({
exclude: [
'/dashboard/**',
'/admin/**',
'/api/private/**',
],
});Built-in defaults always excluded: /api/**, /_next/**, /robots.txt, /sitemap.xml, /favicon.ico, /llms.txt.
License
MIT
