Storybook for Svelte tutorial
Storybook runs alongside your app in development mode. It helps you build UI components isolated from the business logic and context of your app. This edition of the Intro to Storybook tutorial is for Svelte; other editions exist for Vue, Angular, React, React Native and Ember.
Set up Svelte Storybook
We'll need to follow a few steps to get the build process set up in our environment. To start with, we want to use degit to set up our build system. Using this package, you can download "templates" (partially built applications with some default configuration) to help you fast track your development workflow.
Let’s run the following commands:
# Create our application:
npx degit chromaui/intro-storybook-svelte-template taskbox
# Install dependencies
Now we can quickly check that the various environments of our application are working properly:
# Run the test runner (Jest) in a terminal:
# Start the component explorer on port 6006:
# Run the frontend app proper on port 5000:
Our three frontend app modalities: automated test (Jest), component development (Storybook), and the app itself.
Depending on what part of the app you’re working on, you may want to run one or more of these simultaneously. Since our current focus is creating a single UI component, we’ll stick with running Storybook.
At this stage it's safe to add our files to a local repository. Run the following commands to initialize a local repository, add and commit the changes we've done so far.
git add .
git commit -m "first commit"
git branch -M main
Let's start building our first component!