Rsbuild is built on Rspack, so any configuration you apply in Rsbuild can work with raw Rspack projects too. This guide shows how to connect Storybook Rsbuild to an existing Rspack setup.
Explore the Rspack React sandbox for a complete reference implementation.
Starting from a React example, install storybook-react-rsbuild (see the React framework guide) and add the Rsbuild packages required for Rspack support.
Ensure the following packages are present:
storybook@rsbuild/core@rsbuild/plugin-reactstorybook-react-rsbuildrsbuild.config.tsStorybook Rsbuild reads the project's Rsbuild config in the same way that @storybook/builder-webpack5 allows custom webpack configs. Configure the basics for your Rspack app here.
.storybook/main.tsMatch the setup from the React framework guide so Storybook uses the Rsbuild builder.
At this point npx storybook dev should launch using the default @rsbuild/core and @rsbuild/plugin-react configuration. If your stories require additional Rspack features, continue with the next step.
Projects often maintain both rspack.config.ts (for the application build) and rsbuild.config.ts (for Storybook). Import the former into the latter and merge any rules or plugins through tools.rspack. Refer to tools.rspack for every customization hook.
The example below reuses a less-loader rule defined in rspack.config.cjs: