Introducing a new way to review your PRs.

Read the announcement

frappe / frappe-ui

The all-in-one toolkit for modern frontends. High-quality components, app recipes and AI-ready docs.

View on GitHub

28 documents · Updated Nov 23, 2026

docs / vitepress-integration

VitePress integration

The frappe-ui/vitepress package entry provides a shared VitePress experience for documentation sites. It joins a Vue runtime surface for layouts and documentation UI with a Node configuration surface that assembles site settings, content helpers, and build support.

Integration surface

The integration has separate runtime and configuration roles behind one package subpath. VitePress loads the Node side while it reads a site config. Vue code loads the browser/SSR side for the rendered theme. The package export map selects the role by context, while its type entry presents both surfaces to editors. (See the related build and framework integration page and Vite plugins and generators page.)

Consumer contextMain capabilityEntry behavior
Vue runtimeShared docs theme, layouts, docs widgets, sidebar helpers, and shared UI statefrappe-ui/vitepress resolves to the runtime barrel
VitePress Node configSite config builder, content transforms, colocated-doc helpers, sidebar helpers, and build chunk safetyThe node export condition resolves to the Node entrypoint
TypeScript editorOne view of both named API surfacesThe types condition combines the runtime and Node declarations

The subpath is an unstable integration surface. It is intended for supported documentation-site use rather than product application code, so consumers must expect its shape to change without the normal compatibility window. References: package.json• L85-89, vitepress/index.ts• L1-20, vitepress/index.node.ts• L1-10, vitepress/index.d.ts• L1-17

Runtime theme

The runtime theme gives a VitePress site a shared visual and documentation layer. It supplies the main layout and reusable documentation widgets such as component previews, property tables, slot tables, event tables, playground frames, search, navigation, and command-palette UI. It also exposes site-wide actions for an optional repository link and a light, dark, or system color scheme. Importing the theme also brings in its stylesheet, so the theme is the main runtime starting point rather than a collection of unrelated widgets.

The runtime barrel also exposes the shared layout components, site actions, sidebar link helpers, sidebar types, and reactive state used by the docs UI. A consuming site can use the complete theme or compose selected pieces around its own VitePress layout. References: vitepress/index.ts• L8-20, vitepress/…/index.ts• L1-24, vitepress/…/index.ts• L1-5, vitepress/…/SiteActions.vue• L1-27, vitepress/…/SiteActions.vue• L29-67, vitepress/…/index.ts• L1-15, vitepress/state.ts• L1-10

Theme adoption

The normal theme flow starts with the site theme entry. It imports the shared theme, then exports it directly or extends it with site-specific layout behavior. The repository's own docs site follows this model and adds its marketing layout and a router for components that expect Vue Router links.

This diagram shows how a VitePress page receives the shared theme and how a site can add local behavior without replacing the shared docs layer.

flowchart LR
    A[VitePress theme entry] --> B[frappe-ui/vitepress runtime theme]
    B --> C[Shared layout and docs widgets]
    A --> D[Site-specific layout and app setup]
    C --> E[Rendered documentation page]
    D --> E

The runtime theme is for the browser and SSR side of VitePress. The Node config entry must not be used as a Vue theme because it includes configuration-time helpers and does not expose Vue single-file components.

References: vitepress/index.ts• L1-20 vitepress/…/index.ts• L1-24 docs/…/index.ts• L1-30

Node configuration

The Node entrypoint exposes defineDocsConfig, a config builder that turns site identity, navigation, and optional content settings into a VitePress configuration. It establishes the content root, clean URLs, last-updated data, code highlighting, local search, site metadata, aliases, server access, server-rendering rules, and build safeguards as one consistent site baseline.

The builder keeps site-specific information in the caller while it supplies shared behavior. The caller provides a docs root, site name, description, sidebar tree, and optional branding or extension hooks. Optional source roots and colocated-doc settings connect component source to documentation pages when a site needs that feature. References: vitepress/index.node.ts• L30-64, vitepress/index.node.ts• L118-171, vitepress/index.node.ts• L201-236

Configuration inputs

The configuration contract separates required site identity from optional integration features. This lets a general documentation site use the shared baseline without adopting the repository's component-doc workflow.

Input groupRole
Site identitySets the root, name, description, base URL, version, logo, and GitHub link
NavigationSupplies the sidebar tree rendered by the shared navigation UI
Content integrationAdds source roots, component markdown transforms, and optional colocated documentation
Site extensionAdds aliases, head tags, and extra Markdown configuration

The Node entrypoint also re-exports sidebar types and link helpers. It re-exports the content plugins so a site can opt into those capabilities directly when the higher-level config builder is not enough.

References: vitepress/index.node.ts• L33-64 vitepress/index.node.ts• L239-250 vitepress/…/index.ts• L1-12

Build output safety

The shared build setup pre-bundles dependencies pulled in by the common theme so development startup does not trigger repeated dependency optimization reloads. It keeps framework code and editor core code in stable shared chunks. It also checks the final output for a framework-to-theme dependency cycle, because that cycle can fail page startup before the theme is ready. This protects both normal VitePress pages and pages that load the code editor or other shared Vue packages.

The safeguard is part of the Node configuration path. Sites that use defineDocsConfig receive the same startup dependency set, chunk layout, and a build error when the output still contains the unsafe dependency direction. Page-specific heavy dependencies remain local to the pages that use them. References: vitepress/…/preventCircularChunks.ts• L3-26, vitepress/…/preventCircularChunks.ts• L34-69, vitepress/index.node.ts• L66-102, vitepress/index.node.ts• L170-198

Documentation content flow

The integration connects source content to VitePress in two levels. The config builder sets the normal Markdown and page environment. Optional content tools then enrich Markdown with component examples and can create proxy pages for documentation stored next to source components.

Component content tags use the configured source roots to find the story, type, or playground source that backs a page. The transformer turns those tags into rendered Vue content plus source snippets. If a site does not configure source roots, the component tags are left in place and the integration warns instead of guessing a legacy path.

When the colocated-doc option is enabled, a site first seeds proxy pages before VitePress scans its content directory. The Vite plugin then keeps those proxies aligned during development. This allows source-adjacent docs to appear in the site's normal navigation without requiring every page to be copied by hand.

This diagram shows the supported path from site configuration and source roots to rendered documentation.

flowchart TD
    A[Site config] --> B[defineDocsConfig]
    C[Configured source roots] --> D[Component content tools]
    B --> E[VitePress content environment]
    D --> E
    E --> F[Markdown pages and component demos]
    F --> G[Shared runtime theme]
    G --> H[Documentation site]

The repository's docs site uses the separate sync step to seed colocated pages, then passes the same source-root map to the config builder for live updates. This pattern is useful when source code and its docs must move together. References: vitepress/index.node.ts• L151-159, vitepress/index.node.ts• L184-190, vitepress/…/componentTransformer.ts• L17-46, vitepress/…/componentTransformer.ts• L264-337, vitepress/…/index.ts• L1-12, docs/…/config.ts• L18-26, docs/…/config.ts• L150-190

Export selection

The package uses export conditions to keep Node configuration code away from the browser bundle and Vue components away from the Node config loader. TypeScript uses a combined declaration file because editor resolution does not otherwise apply the same runtime condition split.

At runtime, the default entry serves Vue code and the node entry serves VitePress configuration code. At type-check time, the combined declaration makes both named surfaces visible without changing which code runs. References: package.json• L85-89, vitepress/index.d.ts• L1-27

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the package export conditions aligned with the runtime and Node entrypoints. A mismatch can make a Node config load Vue code or make a browser build load Node code.
  • Keep vitepress/index.d.ts aligned with both runtime barrels. Otherwise editor types can disagree with the entrypoint selected at runtime.
  • Keep the shared sidebar data shape aligned with DefineDocsConfigOptions.sidebar and the runtime navigation components.
  • When changing source-root or colocated-doc behavior, check both the initial proxy sync and the development Vite plugin path. The roots used by Markdown transforms must also point to the source files used for snippets and demos.
  • When changing theme components or browser aliases, verify that the Node config remains free of Vue single-file component imports.
  • When changing shared theme dependencies, keep the Node entrypoint's dependency pre-bundle list aligned with the packages used by the theme. Do not add page-specific heavy dependencies to the common startup set.
  • When changing dependency chunk rules, check that framework code does not import the theme chunk and that editor core keeps one shared class identity across full and lean page chunks.

Important failure modes

TriggerConsequenceGuard
A consumer imports the Node-only surface from browser or SSR codeVue theme features are unavailable or Node-only modules enter the client graphUse the default runtime entry for Vue code and reserve the node condition for VitePress config loading
The type declaration omits a newly exported runtime or Node nameEditors reject a valid import or suggest an incomplete APIUpdate the combined index.d.ts surface with each public export change
A site enables component content tags without valid source rootsPreviews, type snippets, or playgrounds do not resolvePass source roots that contain the component stories, types, and playground files
A site enables colocated docs without valid source and proxy rootsComponent pages are not seeded or do not track their source docsPass matching absolute source roots and proxy directories to the sync and watcher paths
A sidebar tree does not match the shared sidebar data contractNavigation is incomplete or the shared sidebar cannot render the supplied sectionsTreat the sidebar type and the runtime sidebar as one contract
The common dependency pre-bundle list names a package that the site does not installVitePress config loading or development startup fails before pages renderKeep the list limited to dependencies used by the shared theme and present in the package's supported dependency set
The build leaves a framework-to-theme chunk edgeThe page can fail during module initialization with a temporal-dead-zone errorKeep shared Vue ecosystem packages in the framework boundary and let the build check reject the cycle
The build duplicates editor core classes across page chunksEditor extensions can reject values from a different class copyKeep editor core in one shared chunk while language grammars remain lazy
A site treats the unstable subpath as a frozen product APIA package update can break the site without a deprecation periodKeep usage within supported documentation sites and review the entrypoint on package upgrades

Key files

FileWhy to read it
package.jsonDefines the frappe-ui/vitepress export conditions and the files included in the package
vitepress/index.tsShows the browser and SSR runtime surface
vitepress/index.node.tsDefines the Node config builder and Node-side content and build exports
vitepress/index.d.tsExplains the combined TypeScript view of both entrypoints
vitepress/…/index.tsShows the shared theme composition and global docs components
vitepress/…/SiteActions.vueShows the shared repository link and color-scheme controls exposed by the runtime surface
vitepress/…/index.tsShows the reusable documentation UI surface
vitepress/…/index.tsShows the optional Markdown and colocated-doc tooling surface
vitepress/…/componentTransformer.tsExplains how component examples and source snippets connect to configured source roots
vitepress/…/preventCircularChunks.tsExplains the build boundary and checks that prevent unsafe VitePress chunk graphs
docs/…/config.tsDemonstrates how an application documentation site supplies the shared config inputs
docs/…/index.tsDemonstrates extending the shared runtime theme with site-specific behavior