v5.0 now supports SvelteKit ProjectsRead docs

Quick Start

Add accept-md to a Next.js or SvelteKit project in under two minutes.

Install

Run from your project root:

Terminal
npx accept-md init

The 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:

Terminal
npx accept-md init

The 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:

Example requests
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

Standard requests still receive HTML. No performance impact for regular visitors.

Configuration

Edit accept-md.config.js in your project root:

accept-md.config.js
/** @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 handler
  • npx accept-md doctor [path] – Report detected router, routes, and issues
  • npx 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