React

Storybook for React & Rsbuild lets you develop and test React components in isolation using the Rsbuild toolchain your app already relies on.

Requirements
  • react ≥ 16.8
  • @rsbuild/core ≥ 1.0.1
  • storybook ≥ 9.0.0

Getting started

Follow these steps inside an existing Rsbuild-powered React project.

Installation

Install the framework package to enable React support.

npm
yarn
pnpm
bun
npm install storybook-react-rsbuild -D

Configure .storybook/main.ts

import { StorybookConfig } from 'storybook-react-rsbuild'

const config: StorybookConfig = {
  framework: 'storybook-react-rsbuild',
  rsbuildFinal: (config) => {
    // Customize the final Rsbuild config here
    return config
  },
}

export default config

That's it! Explore the React 16 and React 18 sandboxes for full examples, and continue learning from the Storybook documentation.

Options

Refer to the framework's types.ts for the complete option list.