Static markdown middleware for Node.js.

Usage no npm install needed!

<script type="module">
  import tinyhttpMarkdown from 'https://cdn.skypack.dev/@tinyhttp/markdown';



npm GitHub Workflow Status Coverage

Static markdown middleware for Node.js.


pnpm i @tinyhttp/markdown


markdownStaticHandler(dir, options)

Handles static files and transforms markdown in HTML in a specified directory. It tries to assign root to README.md or index.md (and with .markdown extension too) in case any of them exists.


  • prefix - URL prefix to add to routes and remove from file paths
  • stripExtension - remove .md (or .markdown) extension from markdown files. Enabled by defaults.
  • markedOptions - initial marked options to be used by the handler.
  • caching settings for Cache-Control header. Disabled by default.


import { App } from '@tinyhttp/app'
import { markdownStaticHandler as md } from '@tinyhttp/markdown'

new App()
    md('docs', {
      prefix: '/docs',
      stripExtension: true,
      markedExtensions: [{ headerIds: true }]