For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /guide/migration.md.
close

Migration

This guide covers migrating an existing Storybook project from the webpack5 or Vite framework to Storybook Rsbuild (e.g. storybook-react-rsbuild).

Using an AI coding agent?

Your agent can handle this migration automatically. Install the agent skills and ask it to migrate your project:

npm
yarn
pnpm
bun
deno
npx skills add rstackjs/agent-skills --skill storybook-rsbuild
Storybook versions

Match your Storybook version to the correct storybook-rsbuild release:

StorybookStorybook Rsbuild
v11^4
v10^3
v9^2
v8^1
React 18+

Storybook 11 removed the React legacy root API. Remove legacyRootApi from framework.options; React 18 or 19 is required.

Dropped peer versions

v4 drops support for legacy peer versions. Upgrade before you move to v4.

@rsbuild/core must resolve to ^2.0.0. Rsbuild 1.x and Rspack 1.x are no longer supported; projects that need them stay on Storybook Rsbuild ^3.

react-native-web must resolve to ^0.19.12 || ^0.20.0 || ^0.21.0 when you use the React Native Web framework; the previous floor was 0.19.0.

@modern-js/app-tools must resolve to ^3.0.0 when you use the Modern.js addon. Modern.js 2 is no longer supported, and @modern-js/plugin-v2 is no longer a peer.

@rslib/core must resolve to >= 0.22.0 when you use the Rslib addon; 0.20 and 0.21 build against Rsbuild 2 pre-releases.

React builder docgen packages are optional peers

react-docgen and react-docgen-typescript are now optional peer dependencies of storybook-react-rsbuild and storybook-react-native-web-rsbuild, so projects on server-side docgen no longer install them, nor the Babel toolchain that react-docgen brings along. typescript is now a required peer dependency of the React, Vue 3, React Native Web, and Web Components frameworks.

Only projects whose .storybook/main.ts sets features.docgenServer: false are affected. Builder docgen loads these packages only when it runs; if one is missing, storybook dev and storybook build fail with the install command for your package manager. Add the packages for your typescript.reactDocgen mode to devDependencies:

typescript.reactDocgenAdd to devDependencies
'react-docgen' (default)react-docgen
'react-docgen-typescript'react-docgen-typescript

There is no plugin package to install for react-docgen-typescript: storybook-react-rsbuild ships its own plugin. In that mode react-docgen is optional and only documents JavaScript files; without it, JavaScript components get no props, and Storybook does not warn about that. Without a usable typescript (not installed, or TypeScript 7, which has no compiler API), react-docgen-typescript falls back to react-docgen.

Set typescript.reactDocgen: false to run without docgen, or better, remove docgenServer: false to use server-side docgen. Storybook does not add these packages when you upgrade.

Info

htmlLang main-config option removed htmlLang is no longer a main-config option, to match upstream Storybook, and the preview <html> element is always lang="en". To set a language, use the htmlLang story parameter (parameters.htmlLang), which sets lang on the story root element (story view) or the embedded story canvas (docs view), not on the iframe <html>. Use parameters.docs.lang for the language of docs prose such as descriptions; Storybook's own UI stays English. Both parameters are available since Storybook 10.5 (storybook#35321).

From Storybook Webpack5 Framework

If your .storybook/main.ts uses a webpack5 framework package (e.g. @storybook/react-webpack5, @storybook/vue3-webpack5), follow this section.

1. Replace packages

Uninstall the old webpack5 framework package, and install the Rsbuild equivalent along with @rsbuild/core.

For example, to migrate a React project:

npm
yarn
pnpm
bun
deno
npm install @rsbuild/core storybook-react-rsbuild -D

Then remove the old packages:

npm
yarn
pnpm
bun
deno
npm remove @storybook/builder-webpack5 @storybook/react-webpack5

The framework package (e.g. storybook-react-rsbuild) includes storybook-builder-rsbuild as a dependency — you do not need to install the builder separately.

Package mapping

Old (webpack5)New (Rsbuild)
@storybook/react-webpack5storybook-react-rsbuild
@storybook/vue3-webpack5storybook-vue3-rsbuild
@storybook/html-webpack5storybook-html-rsbuild
@storybook/web-components-webpack5storybook-web-components-rsbuild

2. Update .storybook/main.ts

.storybook/main.ts
// Before
// import type { StorybookConfig } from '@storybook/react-webpack5'
// After
import type { 
import StorybookConfig
StorybookConfig
} from 'storybook-react-rsbuild'
const
const config: StorybookConfig
config
:
import StorybookConfig
StorybookConfig
= {
// Before: framework: '@storybook/react-webpack5',
framework: string
framework
: 'storybook-react-rsbuild',
stories: string[]
stories
: ['../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
} export default
const config: StorybookConfig
config

3. Convert webpackFinal to rsbuildFinal

Use

mergeRsbuildConfig for modifications Always use mergeRsbuildConfig from @rsbuild/core to modify the config. Directly mutating properties like config.tools.rspack = {...} may not work because internal configs can be arrays of functions/objects, and direct assignment may be silently ignored.

.storybook/main.ts
import type { 
import StorybookConfig
StorybookConfig
} from 'storybook-react-rsbuild'
import {
import mergeRsbuildConfig
mergeRsbuildConfig
} from '@rsbuild/core'
const
const config: StorybookConfig
config
:
import StorybookConfig
StorybookConfig
= {
framework: string
framework
: 'storybook-react-rsbuild',
stories: never[]
stories
: [],
// Before: // webpackFinal: async (config) => { // config.resolve.alias['@components'] = path.resolve(__dirname, '../src/components') // config.module.rules.push({ test: /\.svg$/, use: ['@svgr/webpack'] }) // return config // }, // After:
rsbuildFinal: (config: any) => Promise<any>
rsbuildFinal
: async (
config: any
config
) => {
return
import mergeRsbuildConfig
mergeRsbuildConfig
(
config: any
config
, {
resolve: {
    alias: {
        '@components': string;
    };
}
resolve
: {
alias: {
    '@components': string;
}
alias
: {
'@components': './src/components', }, }, // For SVG, use @rsbuild/plugin-svgr }) }, } export default
const config: StorybookConfig
config
Use relative paths in

resolve.alias Rsbuild resolves alias values relative to the project root. Use './src/components', not path.resolve(__dirname, '../src/components'). The relative form is shorter and avoids __dirname issues in ESM configs.

4. Handle webpack-dependent addons

Some Storybook addons use webpackFinal internally. List them in webpackAddons. If an addon also provides UI or other preset hooks, keep it in addons too:

.storybook/main.ts
import type { 
import StorybookConfig
StorybookConfig
} from 'storybook-react-rsbuild'
const
const config: StorybookConfig
config
:
import StorybookConfig
StorybookConfig
= {
framework: string
framework
: 'storybook-react-rsbuild',
stories: never[]
stories
: [],
// Regular addons (framework-agnostic)
addons: string[]
addons
: ['@storybook/addon-docs', '@storybook/addon-onboarding'],
// Addons that depend on webpack loaders/plugins
webpackAddons: string[]
webpackAddons
: ['@storybook/addon-coverage'],
} export default
const config: StorybookConfig
config

Only addons listed in webpackAddons have their webpackFinal run, and only that hook is applied. The returned config is merged into the Rspack config as is, which works because Rspack is compatible with webpack's loader/plugin API.

Common addons that need

webpackAddons A few addons hook webpackFinal internally and must be listed in webpackAddons (or be replaced with the Rsbuild-native equivalent):

If an addon's name ends in -webpack or its docs mention webpackFinal, assume it needs this treatment. Silently dropping a webpack-only addon is a regression even if storybook build still passes.

5. Convert common webpack patterns

webpack patternRsbuild equivalent
config.resolve.aliasresolve.alias in rsbuildFinal
config.resolve.extensionsresolve.extensions (Rsbuild has sensible defaults)
config.module.rules (loaders)tools.rspack or Rsbuild plugins
config.plugins (webpack plugins)tools.rspack for Rspack plugins
DefinePluginsource.define
css-loader / style-loaderBuilt-in, use tools.cssLoader if customizing
sass-loader@rsbuild/plugin-sass
less-loader@rsbuild/plugin-less
file-loader / url-loaderBuilt-in asset modules
SVGR@rsbuild/plugin-svgr
Rspack plugin compatibility

Not all webpack plugins are compatible with Rspack. Check the Rspack compatibility guide for details.


From Storybook Vite Framework

If your .storybook/main.ts uses a Vite framework package (e.g. @storybook/react-vite, @storybook/vue3-vite), follow this section.

1. Replace packages

Uninstall the old Vite framework package, and install the Rsbuild equivalent along with @rsbuild/core.

For example, to migrate a React project:

npm
yarn
pnpm
bun
deno
npm install @rsbuild/core storybook-react-rsbuild -D

Then remove the old packages:

npm
yarn
pnpm
bun
deno
npm remove @storybook/builder-vite @storybook/react-vite

Package mapping

Old (Vite)New (Rsbuild)
@storybook/react-vitestorybook-react-rsbuild
@storybook/vue3-vitestorybook-vue3-rsbuild
@storybook/html-vitestorybook-html-rsbuild
@storybook/web-components-vitestorybook-web-components-rsbuild

2. Update .storybook/main.ts

.storybook/main.ts
// Before
// import type { StorybookConfig } from '@storybook/react-vite'
// After
import type { 
import StorybookConfig
StorybookConfig
} from 'storybook-react-rsbuild'
const
const config: StorybookConfig
config
:
import StorybookConfig
StorybookConfig
= {
// Before: framework: '@storybook/react-vite',
framework: string
framework
: 'storybook-react-rsbuild',
stories: string[]
stories
: ['../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
} export default
const config: StorybookConfig
config

3. Convert viteFinal to rsbuildFinal

.storybook/main.ts
import type { 
import StorybookConfig
StorybookConfig
} from 'storybook-react-rsbuild'
import {
import mergeRsbuildConfig
mergeRsbuildConfig
} from '@rsbuild/core'
const
const config: StorybookConfig
config
:
import StorybookConfig
StorybookConfig
= {
framework: string
framework
: 'storybook-react-rsbuild',
stories: never[]
stories
: [],
// Before: // viteFinal: async (config) => { // config.resolve.alias['@'] = path.resolve(__dirname, '../src') // return config // }, // After:
rsbuildFinal: (config: any) => Promise<any>
rsbuildFinal
: async (
config: any
config
) => {
return
import mergeRsbuildConfig
mergeRsbuildConfig
(
config: any
config
, {
resolve: {
    alias: {
        '@': string;
    };
}
resolve
: {
alias: {
    '@': string;
}
alias
: {
'@': './src', }, }, }) }, } export default
const config: StorybookConfig
config
Use relative paths in

resolve.alias Rsbuild resolves alias values relative to the project root. Use './src', not path.resolve(__dirname, '../src'). The relative form is shorter and avoids __dirname issues in ESM configs.

4. Convert common Vite patterns

Vite patternRsbuild equivalent
resolve.aliasresolve.alias in rsbuildFinal
plugins: [react()]Auto-configured by framework package
css.preprocessorOptions@rsbuild/plugin-sass or @rsbuild/plugin-less
definesource.define
server.proxyserver.proxy
build.targetoutput.target
Vite plugins are not compatible

Vite plugins cannot be used with Rsbuild. Find equivalent Rsbuild plugins at the Rsbuild plugin list.


Verification

After migration, verify:

  1. npx storybook dev starts without errors
  2. All stories render correctly
  3. HMR works (edit a component, see it update)
  4. npx storybook build completes successfully
  5. Addons function correctly (especially docs, controls, actions)

Debugging

Enable Rsbuild debug mode to inspect the generated config:

DEBUG=rsbuild storybook dev

Check the CLI output to see where the Rsbuild and Rspack configs are written.