Install Storybook
Use the Storybook CLI to install it in a single command. Run this inside your existing projectβs root directory:
If you run into issues with the installation, check the Troubleshooting section below for guidance on how to solve it.
storybook init
is not made for empty projects
Storybook needs to be installed into a project that is already set up with a framework. It will not work on an empty project. There are many ways to bootstrap an app in a given framework, including:
- π¦ Create an Angular Workspace
- π¦ Create React App
- π¦ Create a Vue App
- π¦ Ember CLI
- Or any other tooling available.
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.
Depending on your framework, first, build your app and then check that everything worked by running:
It will start Storybook locally and output the address. Depending on your system configuration, it will automatically open the address in a new browser tab, and you'll be greeted by a welcome screen.
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
Below are some of the most common installation issues and instructions on how to solve them.
- Add the
--type react
flag to the installation command to set up Storybook manually:
-
Storybook's CLI provides support for both Yarn and npm package managers. If you have Yarn installed in your environment but prefer to use npm as your default package manager add the
--use-npm
flag to your installation command. For example: -
Storybook supports Webpack 5 out of the box. If you're upgrading from a previous version, run the following command to enable it:
Check the Migration Guide for more information on how to set up Webpack 5.
- For other installation issues, check the React README for additional instructions.
If all else fails, try asking for help.
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.
Now that you installed Storybook successfully, letβs take a look at a story that was written for us.