Storybook Docs

Install Storybook

Use the Storybook CLI to install it in a single command. Run this inside your project’s root directory:

Code Snippets
Oh no! We could not find the code you are looking for.
It would be great if you could report an issue on Github if you see that message.
Install a specific version

The init command will use whichever version you specify. For example:

  • storybook@latest init will initialize the latest version
  • storybook@7.6.10 init will initialize 7.6.10
  • storybook@7 init will initialize the newest 7.x.x version

Storybook will look into your project's dependencies during its install process and provide you with the best configuration available.

The command above will make the following changes to your local environment:

  • πŸ“¦ Install the required dependencies.
  • πŸ›  Setup the necessary scripts to run and build Storybook.
  • πŸ›  Add the default Storybook configuration.
  • πŸ“ Add some boilerplate stories to get you started.
  • πŸ“‘ Set up telemetry to help us improve Storybook. Read more about it here.
Watch a video tutorial on the Storybook channel

Start Storybook

Storybook comes with a built-in development server featuring everything you need for project development. Depending on your system configuration, running the storybook command will start the local development server, output the address for you, and automatically open the address in a new browser tab where a welcome screen greets you.

Code Snippets
Oh no! We could not find the code you are looking for.
It would be great if you could report an issue on Github if you see that message.

Storybook collects completely anonymous data to help us improve user experience. Participation is optional, and you may opt-out if you'd not like to share any information.

There are some noteworthy items here:

  • A collection of useful links for more in-depth configuration and customization options you have at your disposal.
  • A second set of links for you to expand your Storybook knowledge and get involved with the ever-growing Storybook community.
  • A few example stories to get you started.

Troubleshooting

Run Storybook with other package managers

The Storybook CLI includes support for the industry's popular package managers (e.g., Yarn, npm, and pnpm) automatically detecting the one you are using when you initialize Storybook. However, if you want to use a specific package manager as the default, add the --package-manager flag to the installation command. For example:

Code Snippets
Oh no! We could not find the code you are looking for.
It would be great if you could report an issue on Github if you see that message.

The CLI doesn't detect my framework

If you're working with a custom environment set up or need set up Storybook manually, you can use the --type flag to specify the framework you need to use. Listed below are the supported frameworks and examples of how to use them:

| Framework | Type | | -------------- | ---------------- | | Angular | angular | | Ember | ember | | HTML | html | | Next.js | nextjs | | Preact | preact | | Qwik | qwik | | React | react | | Server | server | | Solid | solid | | Svelte | svelte | | Vue 3 | vue3 | | Web Components | web_components |

Code Snippets
Oh no! We could not find the code you are looking for.
It would be great if you could report an issue on Github if you see that message.

Yarn Plug'n'Play (PnP) support with Storybook

If you've enabled Storybook in a project running on a new version of Yarn with Plug'n'Play (PnP) enabled, you may notice that it will generate node_modules with some additional files and folders. This is a known constraint as Storybook relies on some directories (e.g., .cache) to store cache files and other data to improve performance and faster builds. You can safely ignore these files and folders, adjusting your .gitignore file to exclude them from the version control you're using.

Run Storybook with Webpack 4

If you previously installed Storybook in a project that uses Webpack 4, it will no longer work. This is because Storybook now uses Webpack 5 by default. To solve this issue, we recommend you upgrade your project to Webpack 5 and then run the following command to migrate your project to the latest version of Storybook:

Code Snippets
Oh no! We could not find the code you are looking for.
It would be great if you could report an issue on Github if you see that message.

The installation process seems flaky and keeps failing

If you're still running into some issues during the installation process, we encourage you to check out the following resources:

Join the community

6,378 developers and counting
Open source software
Maintained by
Chromatic
Special thanks to Netlify and CircleCi