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.

Putting it all togetherLink

A real-world plugin that caches an expensive transform, reports progress, resolves a path, and registers a virtual module:

ts
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 alsoLink

Last updated on October 18, 2026

Was this page helpful?