Everything about md.config.ts, route patterns, handler functions, and integration strategies.
The configuration file is the single source of truth for all your markdown routes. It exports an array of route handlers created with createMdVersion:
The main function for defining markdown routes. It takes a pattern, a handler, and optional configuration:
| Param | Type | Description |
|---|---|---|
pattern | string | Next.js-style route pattern (/path, /path/[param], /path/[...slug]) |
handler | (params) => Promise<string> | Async function that receives extracted params and returns markdown |
options | object | Optional configuration (see below) |
| Option | Type | Default | Description |
|---|---|---|---|
hintText | string | default message | Custom LlmHint message for this route |
skipHint | boolean | false | Skip LlmHint injection for this route |
Patterns follow Next.js App Router conventions:
TypeScript automatically infers the correct parameter types from your route pattern using the ExtractParams utility type:
There are two ways to connect content negotiation to your Next.js routing: rewrites and middleware.
Uses Next.js native rewrite rules with header conditions. Zero runtime overhead — rewrites are evaluated by the Next.js router before your code runs.
Uses Next.js middleware to intercept requests. Gives you more control but adds slight runtime overhead.
| Aspect | Rewrites | Middleware |
|---|---|---|
| Performance | Zero overhead | Slight overhead |
| Flexibility | Limited | Full control |
| Setup | next.config.ts | middleware.ts |
| Best for | Most projects | Custom logic needed |
Both strategies route matched requests to an internal handler. For App Router, this lives at app/md-api/[[...path]]/route.ts:
createMdApiHandler instead, which returns a Next.js API route handler compatible with NextApiRequest / NextApiResponse.