Documentation
Quick Start
Add accept-md to a Next.js or SvelteKit project in under two minutes.
Install
Run from your project root:
npx accept-md initThe CLI detects your router, creates middleware, adds the handler route, and writes accept-md.config.js. Install dependencies and you're done.
SvelteKit support
The same CLI works for SvelteKit. From your project root:
npx accept-md initThe CLI detects routes/ or src/routes/, generates the handler at src/routes/api/accept-md/[...path]/+server.js (or .ts), writes accept-md.config.js, and wires up src/hooks.server. Works on Vercel out of the box.
Usage
Request any route with the Accept: text/markdown 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/123Standard requests still receive HTML. No performance impact for regular visitors.
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 – Route glob patterns to serve as Markdown
- exclude – Route glob patterns to skip
- cleanSelectors – CSS selectors stripped before conversion
- cache – In-memory cache for Markdown responses
- transformers – Post-process Markdown via
(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
Full API reference, examples, and contribution guide on GitHub README.
Back to home