accept.md

Next.js โ†’ Markdown

Serve Markdown from any Next.js page

When clients send Accept: text/markdown, return clean Markdown. No changes to your pages. Works with App Router, Pages Router, SSG, SSR, and ISR.

Terminal
$ curl -H "Accept: text/markdown" https://your-site.com/

Built for how you ship

Use cases that just work with your existing Next.js setup.

AI crawlers & LLM ingestion

Expose your content as Markdown for indexing and LLM pipelines without changing your app.

Documentation exports

One command to get Markdown from docs sites for offline use or migration.

Content syndication

Reuse the same pages in other systems, newsletters, or tools that consume Markdown.

SEO & tooling

Provide alternate representations for analysis, audits, and content portability.

Zero page changes

Middleware intercepts requests; your components stay HTML. No Puppeteer, no custom server.

How it works

No custom server, no edits to your page components.

1

Middleware intercepts

Requests with Accept: text/markdown are rewritten to an internal handler.

2

Same URL, HTML first

The handler fetches your page as HTML (your app renders once), then converts HTML โ†’ Markdown.

3

Clean Markdown out

Nav/footer stripped, headings/links/images/tables preserved. Response can be cached.

Install in one command

From your Next.js project root. Init detects App vs Pages Router and sets up middleware and handler.

Your project root
$ npx accept-md init

# Then install deps
$ pnpm install

Full documentation โ€” config, CLI (doctor, fix-routes), and manual setup.

Ready to serve Markdown?

Add accept-md to your Next.js app and keep your pages unchanged.