Adding Docs with Storybook

Now that you’re sharing our project with the world, you should think about taking the documentation to the next level. Storybook[79] has rapidly become a popular library for generating documentation pages for React components. Using Storybook, you can integrate live examples with all the information devs need to take full advantage of your components.

Getting Started with Storybook

Storybook has a handy script that you can run with npx to get started:

 $ ​​npx​​ ​​-p​​ ​​@storybook/cli@4.1.11​​ ​​sb​​ ​​init

Once that script finishes, you’ll see that you have some new devDependencies:

 // package.json
 ...
 "devDependencies"​: {
 ...
 "@storybook/react"​: ​"^4.1.11"​,
 "@storybook/addon-actions"​: ​

Get Test-Driven React now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.