API Reference
Complete API reference for Boltdocs — React hooks, layout components, and configuration helpers.
This section provides reference documentation for all public APIs exported by the boltdocs framework packages.
Architecture Overview
Boltdocs splits its modules into separate entrypoints to isolate server-side configurations from browser-side interactive elements:
| Module Import | Purpose | Environment |
|---|---|---|
boltdocs | Project configuration schemas & plugins | Node / Build |
boltdocs/client | Default styled React components, context hooks, & helpers | Browser / SSR |
boltdocs/primitives | Unstyled primitive elements for crafting custom layouts | Browser / SSR |
React Hooks
Hooks let you consume Boltdocs state (active theme, navigation links, locale selections, search indexes) directly in your custom components.
useConfig
Retrieve the parsed global Boltdocs configuration object.
useSearch
Retrieve search query, results, and open/close toggles.
useTheme
Access and toggle between light and dark UI themes.
useNavbar
Retrieve active navigation configurations, logo details, and social links.
useRoutes
Read metadata list for all generated pages.
useBreadcrumbs
Access navigation breadcrumbs for current location.
usePageNav
Determine the logically preceding or following page routes.
useI18n
Manage and switch between different languages/locales.
useVersion
Manage and switch between different documentation versions.
useTabs
Retrieve category tabs and active sliding indicator style values.
useLocation
Wrapper around React Router DOM location hook to access current router path metadata.
useLocalizedTo
Utility hook to automatically append locale and version segments to path links.
Utilities
Helper functions for combining styles, translation indexing, text compilation, and config validation.
cn
Merge Tailwind styles.
getTranslated
Locale lookup utility.
reactToText
Extract JSX plain text.
copyToClipboard
Write to clipboard.
defineConfig
TypeScript config helper.
Command Line Interface (CLI)
Boltdocs includes CLI commands to build, preview, debug, and auto-fix documentation structures.
Plugin Development
References for authors building Boltdocs plugins — the PluginContext shape, the lifecycle hooks, and every enriched namespace (caches, diagnostics, paths, virtual modules, slots, middleware, server, hmr) exposed to plugin code.
PluginContext
Base context object, base fields, and enriched namespaces overview.
Caches
Transform cache, routes cache, and in-memory FIFO cache.
Diagnostics
Structured diagnostic reporting with severity levels.
Paths
Safe workspace path resolution with traversal protection.
Virtual Modules
Runtime virtual module declarations for Vite.
Middleware
Transform middleware pipeline (source, MDX, HTML).
Server
HTTP middleware & server lifecycle hooks.
HMR
Dev-server file watching & custom HMR events.
Type Exports
Import TypeScript interfaces directly from 'boltdocs' (for configuration schemas) or 'boltdocs/client' (for client-side routing elements):
Build Config Types
import type { BoltdocsConfig, BoltdocsPlugin } from 'boltdocs'
Client Context Types
import type { RouteMeta, SidebarGroup, Heading } from 'boltdocs/client'