Migration Guide
This guide will help you migrate your VitePress site from v1.x to v2.x (currently in alpha).Overview
VitePress v2.0 brings significant improvements including Vite 7 support, Shiki v3 integration, and performance enhancements. While most changes are backwards compatible, there are several breaking changes to be aware of.Breaking Changes
If you use third-party Vite plugins, you may encounter type mismatches. See the Vite migration guide for details.
@ts-expect-error or as any if neededmarkdown-it-async is used instead of markdown-it// ❌ Before (v1.x)
const html = md.render(content)
// ✅ After (v2.x)
const html = await md.renderAsync(content)
// ❌ Before (v2.0.0-alpha.12 and earlier)
export default {
markdown: {
cjkFriendly: false
}
}
// ✅ After (v2.0.0-alpha.13+)
export default {
markdown: {
cjkFriendlyEmphasis: false
}
}
// If you were using:
export default {
vite: {
css: {
postcss: {
plugins: [
postcssIsolateStyles({
includeFiles: [/vp-doc\.css/]
})
]
}
}
}
}
// You can now remove explicit includeFiles:
export default {
vite: {
css: {
postcss: {
plugins: [postcssIsolateStyles()]
}
}
}
}
What Changed:
Only
cwd, ignore, dot, and debug are supported in globOptions of createContentLoader.markdown-it-attrs is disabled for fenced code blocks// ❌ Before - Using markdown-it-attrs
// ```js {.my-class}
// code here
// ```
// ✅ After - Use Shiki transformers
export default {
markdown: {
codeTransformers: [
// Add your custom transformer
]
}
}
/* ❌ Before */
.vp-code {
/* styles */
}
/* ✅ After - Use .shiki instead */
.shiki {
/* styles */
}
/* Or be more specific */
pre.shiki {
/* styles */
}
[class*='language-'] pre {
/* styles */
}
// ❌ Before
import { useLocalNav, useSidebar } from 'vitepress/theme'
const localNav = useLocalNav()
const sidebar = useSidebar()
// ✅ After
import { useLayout } from 'vitepress/theme'
const layout = useLayout()
Apply for AI features: https://forms.gle/iyfb5pC2CiiwszUKA
New Features
Take advantage of these new features in v2:Vite 7 Performance
Faster build times and improved development experience with Vite 7.
Shiki v3 Highlighting
Better syntax highlighting with lazy-loaded languages and improved performance.
Async Markdown Rendering
More powerful markdown processing with async support.
Enhanced DocSearch
DocSearch v4 with sidepanel and AI-powered search (beta).
CJK-Friendly Emphasis
Enabled by default for better CJK language support:Distributed Config Files
Support for multiple config files across your project:Custom Display Names for Code Blocks
Testing Your Migration
Troubleshooting
Type errors with third-party Vite plugins
Type errors with third-party Vite plugins
Vite 7 may cause type mismatches with some plugins. Solutions:Or suppress with
as any and report to plugin repository.Custom CSS not applying to code blocks
Custom CSS not applying to code blocks
If your code block styles aren’t working:
- Replace
.vp-codewith.shiki - Check for
vp-adaptive-themeclass usage - Use
pre.shikior[class*='language-'] preselectors
Search styles broken after upgrade
Search styles broken after upgrade
DocSearch v4 changed class names and structure:
- Review custom DocSearch CSS
- Update selectors for navbar search button
- Update modal styles
- Test on mobile viewports
Build fails with 'markdown.render is not a function'
Build fails with 'markdown.render is not a function'
This happens with custom content renderers:
Rollback Instructions
If you need to rollback to v1.x:Getting Help
- Documentation: vitepress.dev
- GitHub Issues: vuejs/vitepress/issues
- Discord: chat.vuejs.org
- Changelog: CHANGELOG.md
For the latest breaking changes and migration notes, always check the official changelog.