Documentation
Get started
Get accept-md running in your Next.js project in minutes.
Quick start
From your Next.js project root, run:
npx accept-md init
This detects App Router vs Pages Router, creates or updates middleware, adds the handler route, and creates accept-md.config.js. Then install dependencies and you’re done.
Usage
Request any route with the Markdown accept header:
curl -H "Accept: text/markdown" https://your-site.com/ curl -H "Accept: text/markdown" https://your-site.com/about curl -H "Accept: text/markdown" https://your-site.com/posts/123
Normal requests still receive HTML; no performance impact for regular users.
Configuration
Edit accept-md.config.js in your project root:
/** @type { import('accept-md-runtime').NextMarkdownConfig } */
module.exports = {
include: ['/**'],
exclude: ['/api/**', '/_next/**'],
cleanSelectors: ['nav', 'footer', '.no-markdown'],
outputMode: 'markdown',
cache: true,
baseUrl: process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : undefined,
};- include – Glob patterns for routes to include
- exclude – Glob patterns to exclude
- cleanSelectors – CSS selectors removed before HTML→Markdown
- cache – Enable in-memory cache for markdown responses
- transformers – Post-process markdown with
(md) => string
CLI
npx accept-md init [path]– Set up middleware and handlernpx accept-md doctor [path]– Report detected router, routes, and issuesnpx accept-md fix-routes [path]– Fix Next.js 15+ dataRoutes manifest if needed
For full details, examples, and contributing, see the GitHub README.
Back to home