Storybook for Svelte & Webpack

Storybook for Svelte & Webpack is a framework that makes it easy to develop and test UI components in isolation for applications using Svelte built with Webpack.

Storybook for Svelte & Webpack is only supported in Svelte projects.

Requirements

  • Svelte ≥ 4.0
  • Webpack ≥ 5.0
  • Storybook ≥ 8.0

Getting started

In a project without Storybook

Follow the prompts after running this command in your Svelte project's root directory:

More on getting started with Storybook.

In a project with Storybook

This framework is designed to work with Storybook 7+. If you’re not already using v7, upgrade with this command:

Automatic migration

When running the upgrade command above, you should get a prompt asking you to migrate to @storybook/svelte-webpack5, which should handle everything for you. In case that auto-migration does not work for your project, refer to the manual migration below.

Manual migration

First, install the framework:

Next, install and register your appropriate compiler addon, depending on whether you're using SWC (recommended) or Babel:

or

More details can be found in the Webpack builder docs.

Finally, update your .storybook/main.js|ts to change the framework property:

Writing native Svelte stories

Storybook provides a Svelte addon maintained by the community, enabling you to write stories for your Svelte components using the template syntax. You'll need to take some additional steps to enable this feature.

Run the following command to install the addon.

The community actively maintains the Svelte CSF addon but still lacks some features currently available in the official Storybook Svelte framework support. For more information, see the addon's documentation.

API

Options

You can pass an options object for additional configuration if needed:

.storybook/main.js
Loading...

The available options are:

builder

Type: Record<string, any>

Configure options for the framework's builder. For this framework, available options can be found in the Webpack builder docs.

Was this page helpful?

Markdown accepted ([link text](url), _italic_, **bold**, etc). Your anonymous feedback will be posted publicly on GitHub.

✍️ Edit on GitHub – PRs welcome!
Storybook
Join the community
6,599 developers and counting
WhyWhy StorybookComponent-driven UI
DocsGuidesTutorialsChangelogTelemetryStatus
CommunityAddonsGet involvedBlog
ShowcaseExploreProjectsComponent glossary
Open source software
Storybook

Maintained by
Chromatic
Special thanks to Netlify and CircleCI