Migrating from VitePress #
If you already have a VitePress documentation site, this guide walks you through moving it to KawaPress.
What Stays the Same and What Changes #
Your Markdown content moves over unchanged in most sites: frontmatter, custom containers, code groups, line highlights, <<< code snippets, <!--@include-->, [[toc]], :tada: emoji shortcodes, and <Badge> all work as written.
Your site configuration and theme extensions are rewritten in KawaPress's own format. KawaPress does not include a VitePress config compatibility layer, because one clear configuration shape is easier to learn and maintain than having two ways to configure the same thing.
Step by Step #
1. Install Dependencies #
Remove vitepress and install kawapress:
npm uninstall vitepress
npm install --save-dev kawapresspnpm remove vitepress
pnpm add --save-dev kawapressyarn remove vitepress
yarn add --dev kawapressA site that writes Markdown and uses the default nagi (凪) preset only needs kawapress. If your pages or components import Vue APIs or .vue files directly, install vue as a development dependency too.
2. Create kawapress.config.ts #
Create kawapress.config.ts in the project root using nagi() from kawapress/nagi, replacing .vitepress/config.ts. Here is the same typical setup in both tools:
import { nagi } from 'kawapress/nagi'
export default nagi({
title: 'My Docs',
srcDir: 'docs',
themeConfig: {
logo: '/logo.svg',
nav: [
{ text: 'Guide', link: '/guide/getting-started', activeMatch: '/guide' },
],
sidebar: {
'/guide/': [
{
text: 'Introduction',
collapsed: false,
items: [
{ text: 'Getting Started', link: '/guide/getting-started' },
],
},
],
},
socialLinks: [
{ icon: 'github', link: 'https://github.com/your-org/your-repo' },
],
},
})import { defineConfig } from 'vitepress'
export default defineConfig({
title: 'My Docs',
srcDir: 'docs',
cleanUrls: true,
themeConfig: {
logo: '/logo.svg',
nav: [
{ text: 'Guide', link: '/guide/getting-started', activeMatch: '/guide/' },
],
sidebar: {
'/guide/': [
{
text: 'Introduction',
collapsed: false,
items: [
{ text: 'Getting Started', link: '/guide/getting-started' },
],
},
],
},
socialLinks: [
{ icon: 'github', link: 'https://github.com/your-org/your-repo' },
],
search: {
provider: 'local',
},
},
})3. Move Content and Public Assets #
- Markdown directory: If your pages live in
docs/, setsrcDir: 'docs'inkawapress.config.tsand leave them where they are. If your pages are in the project root, omitsrcDir. - Public directory: KawaPress reads
publicinsidesrcDirby default (docs/public/whensrcDir: 'docs', orpublic/at the root). If your static files were in.vitepress/public/, move them topublic/. - Clean up
.vitepress/: Remove.vitepress/once you have migrated any custom components or theme code (see below), and replace.vitepress/distand.vitepress/cachewithdistin.gitignore.
4. Update package.json Scripts #
Replace the vitepress CLI commands with kawapress. KawaPress reads kawapress.config.ts from the project root automatically, so no directory argument is needed:
{
"scripts": {
"docs:dev": "kawapress dev",
"docs:build": "kawapress build",
"docs:preview": "kawapress preview"
}
}5. Build and Deploy #
Run kawapress build. Static files are written to dist/ in the site root (instead of .vitepress/dist). Update your hosting platform or CI workflow to publish dist/. See Deploy for hosting and caching details.
Site Configuration Mapping #
This table maps top-level VitePress defineConfig() options to KawaPress:
Default Theme themeConfig Mapping #
This table maps VitePress default theme options to nagi:
Markdown Syntax That Works as Is #
Most VitePress Markdown syntax works without changes:
One small difference to note: inline HTML or components inside a heading (such as <Badge text="beta" />) render in the heading on the page, but their tags are dropped from the plain-text title used by the browser tab, the page outline, [[toc]], and the search index, and they do not change the heading anchor.
Things That Need Changes #
Layout Slots Become Outlets #
Where VitePress wraps the default theme's Layout and fills named slots (#doc-before, #nav-bar-content-after), KawaPress provides eight standard outlets that Runtime Plugins contribute to with api.prependToOutlet() and api.appendToOutlet():
// my-layout-plugin/runtime-plugin.ts
import { defineRuntimePlugin } from 'kawapress'
import DocBanner from './DocBanner.vue'
export default defineRuntimePlugin({
name: 'my-layout-plugin',
setup(api) {
api.prependToOutlet('doc', {
id: 'banner',
component: DocBanner,
})
},
})See Theme Development and Plugin Development for all eight outlets and how they work.
Custom Layout Components #
A whole-page layout that VitePress picks with layout: name plus app.component('name', Component) works the same way in nagi: register a global component with that name in a Runtime Plugin, and place the page content with <RouterView /> instead of <Content />. layout: false also means no theme frame at all. See Frontmatter.
useData() Splits into Focused Composables #
VitePress's useData() and template globals such as $frontmatter are replaced by focused composables exported from kawapress/client:
<script setup lang="ts">
import { usePageData, useSite, useThemeConfig } from 'kawapress/client'
const page = usePageData()
const site = useSite()
const theme = useThemeConfig()
</script>.vitepress/theme/index.ts enhanceApp Becomes a Runtime Plugin #
To register global Vue components, install Vue plugins, or add router hooks, move your enhanceApp({ app, router }) code into a Runtime Plugin:
// my-site-plugin/runtime-plugin.ts
import { defineRuntimePlugin } from 'kawapress'
import DemoBox from './DemoBox.vue'
export default defineRuntimePlugin({
name: 'my-site-plugin',
setup(api) {
api.vueApp((app) => {
app.component('DemoBox', DemoBox)
})
api.router((router) => {
router.afterEach((to) => {
console.log('Navigated to', to.path)
})
})
},
})See Plugin Development for how to wire a Runtime Plugin to its package entry.
Build-Time Data Loaders (*.data.ts) #
Data loaders (*.data.ts and *.data.js) work the same way as in VitePress. Change the import source from 'vitepress' to 'kawapress':
-import { createContentLoader, defineLoader } from 'vitepress'
+import { createContentLoader, defineLoader } from 'kawapress'If a loader reads the global site configuration, replace globalThis.VITEPRESS_CONFIG with globalThis.KAWAPRESS_CONFIG. Also note that KawaPress requires loader return values to be strictly JSON-serializable (Date, Map, Set, and undefined properties fail the build with a clear error). See Build-Time Data Loading.
createMarkdownRenderer() #
If you use VitePress's createMarkdownRenderer() only to render demo sources at build time, import the same-named function from @kawapress/plugin-shiki instead. Shiki grammar options such as languages keep working, and the renderer supports renderAsync(). See Rendering Markdown at build time.
withBase() #
Import withBase() from kawapress/client and pass site.base as the second argument:
<script setup lang="ts">
import { useSite, withBase } from 'kawapress/client'
const site = useSite()
</script>
<template>
<img :src="withBase('/logo.svg', site.base)" alt="Logo">
</template>When you need to strip the base prefix from a URL path, use withoutBase(path, site.base) from kawapress/client.
Not Available #
The following features are not available in KawaPress:
- Team page components (
VPTeamMembers, etc.): KawaPress does not include built-in team components; build team sections with regular Vue components or UnoCSS utilities. - Dynamic route generation (
[pkg].paths.ts): Pages come from Markdown files on disk (with optionalrewrites), without parameterized virtual-page loaders. - Versioned documentation: Built-in multi-version management and version switching are not included.
- Blog, archives, and RSS: Built-in blog layouts and RSS generation are not included, though page indexes can be built with
createContentLoader(). - Per-page
prev/nextfrontmatter: Previous and next links always follow the active sidebar. ::: rawstyle isolation container: Not included.- Carbon Ads integration: Not built into nagi; mount custom components through a Runtime Plugin and an outlet such as
doc.toc.


Comments