next-md
negotiate
Serve markdown to LLMs. HTML to humans. Same URL.
$ npm install next-md-negotiateSee it in action
One header. That's all it takes.
Three steps. Zero complexity.
Define your markdown routes in a single config file. Each route maps a URL pattern to a handler that returns markdown.
HTTP Accept header determines the response format. Browsers get HTML. LLM agents requesting markdown get markdown.
Same URL serves both formats. No duplicate endpoints. No SEO penalties. Crawling budget preserved.
Built for production
Everything you need. Nothing you don't.
Zero Duplicate URLs
Single canonical URL serves both formats. No /api/products/42.md endpoints cluttering your sitemap.
Type-Safe Params
Route parameters are inferred from patterns. TypeScript knows [productId] means { productId: string }.
SEO Neutral
Search engines only see HTML. No duplicate content penalties. Crawling budget stays intact.
LLM Discoverable
Hidden hints tell AI agents markdown is available. They re-request with the right Accept header.
Both Routers
Works with App Router and Pages Router. Same config, same patterns, same API.
One Command Setup
npx next-md-negotiate init detects your project, creates config, sets up routing. Done.
This site runs next-md-negotiate
Every page on this site serves markdown to LLM agents. Try it yourself — request any page with an Accept: text/markdown header.
$ curl -H "Accept: text/markdown" <this-url>