Migrating from Rspress 1.x
This document will help you migrate from Rspress 1.x to Rspress V2. We recommend using the "Copy as Markdown" feature to pass this document to an LLM for automated migration assistance.
Quick migration checklist
- Node.js >= 20.9.0
- Dependencies:
rspress→@rspress/core, remove@rspress/shared - Import paths:
rspress/runtime→@rspress/core/runtime - Custom themes: Change default exports to named exports, use
@rspress/core/theme-original - Top-level navigation:
_meta.json→_nav.json(top-level only) - Code highlighting: Prism → Shiki, line highlight syntax
{1,3-4}requires transformer config - builderPlugins: Move to
builderConfig.plugins - Sass/Less: Manually install
@rsbuild/plugin-sassor@rsbuild/plugin-less - External code blocks:
<code src="..." />→```tsx file="..." - themeConfig.locales: Remove
outlineTitleand other text configs, usei18nSourceinstead
[Important] Node.js and upstream dependency requirements
Node.js Version
Rspress V2 no longer supports Node.js 16 and 18. Please upgrade to Node.js >= 20.9.0. Node.js 22 LTS is recommended.
Upstream dependency versions
If react, react-dom, or react-router-dom is already installed in your project, Rspress will use the project's version instead of the built-in default version.
[Important] Package name and import path changes
Rspress V2 consolidates multiple packages into @rspress/core. The original rspress package is no longer used.
- before:
- after:
If you developed an Rspress plugin, change the plugin's peerDependencies from rspress to @rspress/core:
Import path changes
It's recommended to use a global find-and-replace to update import paths.
Example:
- before:
- after:
Removed standalone packages
The following plugins are now built into the core package and no longer need to be installed separately:
@rspress/plugin-shiki- Shiki code highlighting is now default@rspress/plugin-auto-nav-sidebar- Navigation sidebar is built-in@rspress/plugin-container-syntax- Container syntax is built-in@rspress/plugin-last-updated- Last updated time is built-in@rspress/plugin-medium-zoom- Image zoom is built-in
[Important] Custom theme ESM export changes
Custom themes no longer use default exports. Use named exports instead.
- before:
- after:
Theme import paths
Using theme components in MDX files within the docs directory:
If using the @theme alias, add path mapping in tsconfig.json for type hints:
If you encounter errors about missing exports from @theme or @rspress/core/theme, it's likely because you didn't use @rspress/core/theme-original when overriding the theme in the theme folder, causing a circular reference:
Make sure to use @rspress/core/theme-original in the theme folder and correctly export all components.
[Important] Shiki code highlighting replaces prism
Rspress V2 uses Shiki v3 for code highlighting by default. Prism has been removed.
For the list of languages supported by Shiki, see Shiki Languages. For more Shiki usage, see the Code Blocks documentation.
Configuration migration
- before:
Configure language aliases via highlightLanguages:
- after:
Configure langAlias and other Shiki options via markdown.shiki:
Line highlighting syntax changes
V2 no longer includes the {1,3-4} meta line highlighting syntax by default. Choose from the following options based on your needs:
- Notation Line Highlight: Uses
// [!code highlight]comment syntax, requirestransformerNotationHighlightconfiguration - Meta Line Highlight: Compatible with legacy
{1,3-4}syntax, requirestransformerCompatibleMetaHighlightconfiguration
To maintain compatibility with V1's meta line highlighting syntax, add the following configuration:
[Important] Top-level Navigation file renamed
Rspress V2 separates nav and sidebar configuration. The top-level _meta.json needs to be renamed to _nav.json, while inner files remain unchanged.
- before:
- after:
[Important] SSG strict mode by default
SSG is now in strict mode by default. On failure, the build exits immediately instead of falling back to CSR. The ssg.strict configuration has been removed.
To skip SSG, set ssg: false:
[Important] Features enabled by default
The following features are enabled by default in V2:
To disable lazy compilation:
base configuration reimplemented
The base configuration is now implemented using react-router's basename.
Key changes:
useLocation().pathnameno longer includes thebaseprefix- Use
Link/useNavigatefor navigation instead of directly manipulatingwindow.location
cleanUrls: true Links are shortened
When cleanUrls: true, generated links no longer include the /index suffix.
- before:
/guide/index - after:
/guide/
builderPlugins configuration removed
builderPlugins has been removed. Please migrate to builderConfig.plugins.
- before:
- after:
Sass/Less Requires manual installation
Built-in Sass/Less plugins have been removed. Install them manually if needed:
Then register in configuration:
External code block syntax changed
External code block syntax has changed:
- before:
- after:
Relative link resolution changed
Relative links no longer require the ./ prefix. The following two syntaxes are now equivalent:
MDX file route exclusion
Files starting with underscore _ are automatically excluded from routing, suitable for MDX fragments and React components.
Theme style changes
Tailwind class name prefix
Built-in theme class names now have a Tailwind prefix to avoid conflicts. If you rely on classes like dark:hidden, configure Tailwind/UnoCSS in your project.
Native HTML tag styling
Native HTML tags now have document styling by default. To isolate styling, add the .rp-not-doc class:
Built-in Multilingual text
The default theme now includes built-in multilingual translation text with tree-shaking support based on your project's configured languages.
Key changes:
- If your documentation only includes
enandzh, only those languages will be bundled - For languages not supported by Rspress, it automatically falls back to
en - In most cases, you don't need to manually configure i18n text
The following themeConfig.locales text configurations have been removed. Please delete related configurations:
-
outlineTitle -
lastUpdatedText -
editLink.text -
prevPageText -
nextPageText -
sourceCodeText -
searchPlaceholderText -
searchNoResultsText -
searchSuggestedQueryText -
overview.filterNameText -
overview.filterPlaceholderText -
overview.filterNoResultText -
before:
- after: