Middleware
PluginMiddlewareAPI — register and query transform middleware at runtime for Boltdocs plugins.
ctx.middleware — PluginMiddlewareAPI
Registers transform middleware entries. The name field is optional
— when omitted, the plugin's name is used as the context.
ts
ctx.middleware.add({
name: 'my-plugin:html',
transformHtml: async (_ctx, { html, path }) => ({
html: html.replace('</body>', '<footer>© 2026</footer></body>'),
}),
})
ctx.middleware.has('my-plugin:html') // → boolean
ctx.middleware.list() // → readonly PluginTransformMiddleware[]
ctx.middleware.remove('my-plugin:html')
See also
- PluginContext — base context object
- Server — HTTP middleware and server lifecycle
- HMR — file watching and custom dev server events
Last updated on October 18, 2026