Storybook & Atomic Design – 1.2. – Getting Started with Storybook

Creating a New Instance for React

So the quickest way of getting our Storybook React project setup is to create a directory for your project, I'll be using the directory Storybook on my desktop but you can initialise the project anywhere you feel appropriate.

Within your project directory, we need to create a package.json file for our dependencies to be managed. We can do this by running the following -

npm init

Following the interactive questions to configure the package.json file.

Installing Storybook

After setting up your package file, within your directory, you'll want to run the command -

npx -p @storybook/cli sb init --type react

This command will install the required dependencies and configuration files we need for Storybook to run on our machine.

If for any reason this fails, please refer to the official Storybook documentation on how to complete a manual installation -

If everything went well, you'll see some new directories in your project, these directories contain the core config files for the global project.

As well as these config files, we have access to some example stories and components to give us a structure to follow when composing our own stories.

Starting the development server

With the new assets and files, you'll then need to run the following to start a local development server -

npm run storybook

You should now have a React Storybook instance development server available at http://localhost:6006

I won't be going into how we compose stories just yet, that will come up in a following lesson of this course, for now, take reference of how to navigate to the development server and how we run our storybook instance in development mode.

Creating a Github Repository for the Project

Finally, we will want to create a Github repository for our Storybook project.

Some developers may want to tightly couple the storybook instance with their product repository but I invite you to hold off on doing so as separating the two allows the design system to be used across many products and not isolated to a single system or site.

Initialise Git

So to create a git instance, we first need to run the following within the root directory of our project (ce-storybook/) -

git init


Our project is now a git initialised project, but before we go about committing our project to a git repository, we first want to ignore specific directories related to our packages.

This is because by committing directories such as node_modules to our repository, we are potentially committing tens of thousands of files which are expected to change frequently. Insteadm we will use the package.json file to manage these files and run npm install whenever cloning the codebase or deploying the codebase to a server. Keeping the files outside of the codebase until installed.

To ignore common directories I use the following tool - to generate a file placed in the root directory of my project called .gitignore

Alternatively, you can copy and paste the settings to a .gitignore file which I get when entering windows, macOS, node on the site -

# Created by <,macos,windows>
# Edit at <,macos,windows>

### macOS ###
# General

# Icon must end with two \r

# Thumbnails

# Files that might appear in the root of a volume

# Directories potentially created on remote AFP share
Network Trash Folder
Temporary Items

### Node ###
# Logs

# Diagnostic reports (<>)

# Runtime data

# Directory for instrumented libs generated by jscoverage/JSCover

# Coverage directory used by tools like istanbul

# nyc test coverage

# Grunt intermediate storage (<>)

# Bower dependency directory (<>)

# node-waf configuration

# Compiled binary addons (<>)

# Dependency directories

# TypeScript v1 declaration files

# TypeScript cache

# Optional npm cache directory

# Optional eslint cache

# Optional REPL history

# Output of 'npm pack'

# Yarn Integrity file

# dotenv environment variables file

# parcel-bundler cache (<>)

# next.js build output

# nuxt.js build output

# react / gatsby 

# vuepress build output

# Serverless directories

# FuseBox cache

# DynamoDB Local files

### Windows ###
# Windows thumbnail cache files

# Dump file

# Folder config file

# Recycle Bin used on file shares

# Windows Installer files

# Windows shortcuts

# End of <,macos,windows>

Pushing Our Project to a Github Repository

Now although git and Github may share similar names they are not the same.

Git is version control, it is the core technology used to track, manage and edit your codebase.

Github is one of many platforms used to host the git information and host project files.

You can use git across Github, Bitbucket, Gitlab and more git hosting providers. In this course, we will use Github to create free public and private repositories but the same concepts can be applied to your platform of choice.

With a Github account, you can create a new repository or repo for short by navigating to -

You'll be asked to set a repository name, for which I will use the name 'storybook-atomic-design-react'.

Next, you can set an optional description.

I'll be setting my repository privacy to public for the sakes of this course but you can set yours to private if you are working on a sensitive project or commercial product.

I'll skip over setting up a for now, but it's helpful to use one to document your installation process to ease the onboarding process for those contributing to the project.

You'll then be presented with a quick start guide by Github.

We can use a slightly modified command-line example to help us get our code pushed to the repository.

git remote add origin<github-username>/<project-name>.git
git add -A
git commit -m "Initialise Repository"
git push -u origin master

Now you should see a success message in your command line and have access to your Storybook project on Github.


We now have a version-controlled Storybook React project, ready for us to start customising with our own React components and story files to document our components.

In the next lesson, we'll be removing the default stories that come with our system, setting up a custom directory structure, before we create our first story.

Continue Reading 📚