Migration guide for Storybook 8.0
Storybook 8 focuses on improving performance, compatibility, and stability. Key features include:
- 🩻 A new visual testing workflow via the Visual Tests addon
- 💨 2-4x faster test builds, 25-50% faster React docgen, and SWC support for Webpack projects
- 🧩 Improved framework support: you no longer need to install React as a peer dependency when using a non-React renderer
- 🎛️ Strengthened control generation in React and Vue projects
- ⚡️ Improved Vite architecture, Vitest testing, and Vite 5 support
- 🌐 Support for React Server Components (RSC): our experimental solution renders async RSC in the browser and mocks Node code
- ✨ A refreshed desktop UI & mobile UX
- ➕ Much, much more
This guide is meant to help you upgrade from Storybook 7.x to 8.0 successfully!
Migrating from Storybook 6.x?
We have a dedicated migration guide for Storybook 6 to 8.
Major breaking changes
The rest of this guide will help you upgrade successfully, either automatically or manually. But first, there are some breaking changes in Storybook 8. Here are the most impactful changes you should know about before you go further:
storiesOf
API has been removed*.stories.mdx
format has been removed- Packages have been consolidated/removed
- Implicit actions (from
argTypesRegex
) can no longer be used during rendering (e.g. in a play function) react-docgen
(instead ofreact-docgen-typescript
) is the default for component analysis- Storyshots has been removed
- Addons API introduced in Storybook 7 is now required
- Ecosystem updates
If any of these changes apply to your project, please read through the linked migration notes before continuing.
If any of these new requirements or changes are blockers for your project, we recommend to continue using Storybook 7.x.
You may wish to read the full migration notes before migrating. Or you can follow the instructions below and we’ll try to take care of everything for you!
Automatic upgrade
To upgrade your Storybook:
This will:
- Determine that none of the breaking changes apply to your project
- If they do, you will receive instructions on how to resolve them before continuing
- Upgrade your Storybook dependencies to the latest version
- Run a collection of automigrations, which will:
- Check for common upgrade tasks
- Explain the necessary changes with links to more information
- Ask for approval, then perform the task on your behalf
Common upgrade issues
While we'll do our best to upgrade your project automatically, there is one issue worth mentioning that you might encounter during the upgrade process:
storyStoreV7:false
and storiesOf
If you have storyStoreV7: false
in your .storybook/main.js
, you will need to remove it before you're able to upgrade to Storybook 8.
If you are using the storiesOf
API (which requires storyStoreV7: false
in Storybook 7), you will need to either migrate your stories to CSF or use the new indexer API to continue creating stories dynamically.
Missing vite.config.js
file
If you are using Vite, you may now need to create a vite.config.js
file in your project root to allow newer versions of Vite to work with Storybook. Additionally, you may need to install and configure a Vite plugin for your framework. More information is available in the full migration notes.
New projects
To add Storybook to a project that isn’t currently using Storybook:
This will:
- Figure out which renderer (React, Vue, Angular, Web Components), builder (Webpack, Vite), or meta-framework (Next.js, SvelteKit) you’re using
- Install Storybook 8 and auto-configure it to mirror project settings
Manual migrations
In addition to the automated upgrades above, there are manual migrations that might be required to get Storybook 8 working in your project. We’ve tried to minimize this list to make it easier to upgrade. These include:
*.stories.mdx
to MDX+CSF
Storybook now requires that MDX pages reference stories written in CSF, rather than the previous .stories.mdx
hybrid approach. You can automatically convert your files using the following codemod (make sure to update the glob to fit your files):
You’ll also need to update your stories glob in .storybook/main.js
to include the newly created .mdx and .stories.js files if it doesn’t already.
Known limitations
- The codemod does not remove the extracted stories from the
.stories.mdx
files. You will need to do this manually.
Note: this migration supports the Storybook 6 "CSF stories with MDX docs" recipe.
Troubleshooting
The automatic upgrade should get your Storybook into a working state. If you encounter an error running Storybook after upgrading, here’s what to do:
- Try running the
doctor
command to check for common issues (such as duplicate dependencies, incompatible addons, or mismatched versions) and see suggestions for fixing them. - If you’re running
storybook
with thedev
command, try using thebuild
command instead. Sometimesbuild
errors are more legible thandev
errors! - Check the full migration notes, which contains an exhaustive list of noteworthy changes in Storybook 8. Many of these are already handled by automigrations when you upgrade, but not all are. It’s also possible that you’re experiencing a corner case that we’re not aware of.
- Search Storybook issues on GitHub. If you’re seeing a problem, there’s a good chance other people are too. If so, upvote the issue, try out any workarounds described in the comments, and comment back if you have useful info to contribute.
- If there’s no existing issue, you can file one, ideally with a reproduction attached. We’ll be on top of Storybook 8 issues as we’re stabilizing the release.
If you prefer to debug yourself, here are a few useful things you can do to help narrow down the problem:
- Try removing all addons that are not in the
@storybook
npm namespace (make sure you don't remove thestorybook
package). Community addons that work well with 7.x might not yet be compatible with 8.0, and this is the fastest way to isolate that possibility. If you find an addon that needs to be upgraded to work with Storybook 8, please post an issue on the addon’s repository, or better yet, a pull request to upgrade it! - Another debugging technique is to bisect to older prerelease versions of Storybook to figure out which release broke your Storybook. For example, assuming that the current prerelease of Storybook is
8.0.0-beta.56
, you could set the version to8.0.0-alpha.0
in yourpackage.json
and reinstall to verify that it still works (alpha.0
should be nearly identical to7.6.x
). If it works, you could then try8.0.0-beta.0
, then8.0.0-beta.28
and so forth. Once you’ve isolated the bad release, read through its CHANGELOG entry and perhaps there’s a change that jumps out as the culprit. If you find the problem, please submit an issue or pull request to the Storybook monorepo and we’ll do our best to take care of it quickly.
Package structure changes
The following packages are removed. See the full migration notes for details.
Removal | Replacement |
---|---|
@storybook/addons | @storybook/manager-api or @storyboook/preview-api |
@storybook/channel-postmessage | @storybook/channels |
@storybook/channel-websocket | @storybook/channels |
@storybook/client-api | @storybook/preview-api |
@storybook/core-client | @storybook/preview-api |
@storybook/preview-web | @storybook/preview-api |
@storybook/store | @storybook/preview-api |
@storybook/api | @storybook/manager-api |
The following packages are deprecated. See the full migration notes for details.
Deprecation | Replacement |
---|---|
@storybook/testing-library | @storybook/test |
Optional migrations
In addition to the automigrations and manual migrations above, there are also optional migrations that you should consider. These are features that we’ve deprecated in Storybook 8 (but remain backwards compatible), or best practices that should help you be more productive in the future.
CSF 2 to CSF 3
There are many good reasons to convert your stories from CSF 2 to CSF 3. We provide a codemod which, in most cases, should automatically make the code changes for you (make sure to update the glob to fit your files):