Plugin API Reference
Complete reference for the Boltdocs Plugin API — PluginContext, caches, diagnostics, path resolution, and virtual modules. Covers every field and method exposed to plugin lifecycle hooks.
The PluginContext object passed to every lifecycle hook carries seven
enriched namespaces that give plugins safe, typed access to the core's
internal machinery: caches, diagnostics, paths,
virtual modules, middleware, server, and hmr.
This section is the official API reference. Read it alongside the Plugin System overview for the architecture and examples.
Each namespace has its own dedicated page — use the sidebar or the cards below to navigate.
PluginContext
Base context object passed to every lifecycle hook.
Caches
Transform, routes, and memory caches.
Diagnostics
Structured diagnostic reporting.
Paths
Safe workspace path resolution.
Virtual Modules
Runtime virtual module declarations.
Middleware
Transform middleware pipeline.
Server
HTTP middleware & server lifecycle.
HMR
Dev-server file watching & custom events.
Lifecycle Hooks
Build/dev hooks, transform chains, and chain signals.
Putting it all together
A real-world plugin that caches an expensive transform, reports progress, resolves a path, and registers a virtual module:
import { definePlugin } from 'boltdocs'
export default definePlugin<MyOptions>((options) => ({
name: 'my-smart-plugin',
client: {
slots: {
'header:right': './components/HeaderActions.tsx',
'search:dialog': './components/SearchModal.tsx',
},
providers: ['./providers/SearchProvider.tsx'],
mdxComponents: { Callout: './components/Callout.tsx' },
},
hooks: {
'frontmatter:transform'(ctx, { frontmatter, rawContent }) {
return {
...frontmatter,
readingTime: Math.ceil(rawContent.split(/\s+/).length / 200),
}
},
'search:index'(ctx, { documents }) {
ctx.logger.info(`Indexed ${documents.length} search documents.`)
},
'build:generate'(ctx, { routes, outDir }) {
ctx.logger.info(`Generated assets for ${routes.length} routes in ${outDir}.`)
},
},
}))
See also
- Plugin System overview — architecture, concepts, quick start
- @bdocs/unist-utils — AST utilities for remark/rehype
- Releases — release history
- Boltdocs 3.3.0 release post — detailed release notes