6 Tools for Documenting Your React Components Like a Pro
Tags: react, reactnative, javascript, github
Published: 2019-08-16 12:41:38

###What good are components if nobody can understand how to find and use them?

React encourages you to build modular applications with components. Modularity brings all sorts of advantages, including improved reusability. But, when you aim to share and reuse a component, you better make sure it is easy to discover, understand and put to use. You need to document components.

Today, modern tools can help automate some of the documentation workflows and to turn the consumption of component documentation into a rich, visual and even interactive experience. Some tools even combine such docs as an integral part of the very workflow of sharing components.

To achieve beautiful component documentation without working too hard, I’ve gathered some of the best and most popular tools for documenting React components. Feel free to comment and add your own ideas and tools.

## 1. [Bit](https://bit.dev)

The platform for shared components.

![bit.dev — Search and choose components by bundle-size, dependencies, labels and snapshot previews](https://cdn-images-1.medium.com/max/2642/1*QG7SZrh2BFdFXFjkCP2lMg.png)*bit.dev — Search and choose components by bundle-size, dependencies, labels and snapshot previews*

[Bit](https://bit.dev) more than just a documentation tool for components. It’s an open-source tool that lets you encapsulate components with all their files and dependencies, and run them across different applications out-of-the-box.

The [bit.dev](https://bit.dev) platform lets you share and collaborate on components across your applications. All your shared components are made discoverable for your team to find and use in their projects and easily share their own components.

![](https://cdn-images-1.medium.com/max/2000/1*HNrykRFyylLT_oTiiBDn1Q.gif)

The components you share to [bit.dev](https://bit.dev) become discoverable in your team’s a shared component hub. You can search for components by context, bundle-size or even dependencies. You can quickly browse results based on visual snapshots of the actually-rendered components, and choose with your eyes.

→ [Explore components on bit.dev](https://bit.dev/components)

![](https://cdn-images-1.medium.com/max/2000/1*Gxjhw2nGfLKMDnEPan28lQ.gif)

When you go into one of your component’s web-page, you will discover that Bit presents the component in a live playground so that you can play with it before choosing to consume it in your application. If you have JSDocs or an .md file as part of the code, Bit will parse and present these docs as well. If the components include unit-test files, Bit will run them in isolation and present the results as part of the documentation for every component.

When found a component you like to use, just use NPM or Yarn to install it. You can even use Bit to develop and update the components directly from any consuming application, so your team can collaborate and build together.

![](https://cdn-images-1.medium.com/max/2000/1*gJJ8TKLAYWhX90zWB0UMWA.png)

When sharing components through Bit you don’t have to set up any more repositories or tools, no need to refactor or change your code, and the same hub where you share components are where they become documented and discoverable, pretty much out of the box.

<center><iframe width="560" height="315" src="https://www.youtube.com/embed/E5lgoz6-nfs" frameborder="0" allowfullscreen></iframe></center>


## 2. StoryBook & Styleguidist

StoryBook and StyleGuidist are too wonderful projects that help develop components in isolation while visually rendering and documenting them.

![StoryBook](https://cdn-images-1.medium.com/max/5250/1*pm4qA984LyGnlAGnCyhb_w.png)*StoryBook*

[StoryBook](https://storybook.js.org/)* *is a development environment for UI components. It allows you to browse a component library, view the different states of each component, and interactively develop and test components. When building a library, StoryBook is a neat way to visualize and document components and different AddOns make it easier to integrate into your different tools and workflows. You can even reuse stories in unit-tests to confirm nuanced functionality.

![StyleGuidist](https://cdn-images-1.medium.com/max/2000/1*KS039LFntBGC8gExP7ZqGw.gif)*StyleGuidist*

[StyleGuidist](https://github.com/styleguidist/react-styleguidist) is an Isolated React component development environment with a living style guide. It provides a hot reloaded dev server and a living style guide that lists component propTypes and shows editable usage examples based on .md files. It supports ES6, Flow and TypeScript and works with Create React App out of the box. The auto-generated usage docs can help Styleguidist function as a documentation portal for your team’s different components.

* Also check out [UI Zoo](https://github.com/myheritage/uizoo.js) by [Noam Elboim](undefined).

## 3. Codesandbox, Stackblitz & friends

[Component playgrounds](https://blog.bitsrc.io/11-react-ui-component-playgrounds-for-2018-eef5a87a1bf8) are a neat way to play with components and learn how they work. When you can combine them as part of your documentation (or [as part of your shared-components workflow](https://bit.dev/components)), playgrounds help you quickly learn how code works and decide if you want to use the component.

![Codesandbox](https://cdn-images-1.medium.com/max/2000/1*xUCCCP8hLcAa4vgjKAU_vg.gif)*Codesandbox*

[Codesandbox](https://codesandbox.io/) is an online editor for quickly creating and playing-with small projects like components. After creating something interesting you can show it to others by just sharing the url. CodeSandbox features a live preview to show the result of the code while you’re typing and has extensions built to integrate into your different tools and your development workflow.

![](https://cdn-images-1.medium.com/max/2000/1*ibw0_i_PEheYu--MlgyV5Q.gif)

[Stackblitz](https://stackblitz.com/) is an “online IDE for web applications” powered by Visual Studio Code. Much like Codesnadbox, StackBlitz is an online IDE where you can create Angular & React projects that are made shareable via a URL link. Like Codesandbox, it [automatically takes care](https://medium.com/@ericsimons/stackblitz-online-vs-code-ide-for-angular-react-7d09348497f4) of installing dependencies, compiling, bundling, and hot reloading as you type. Take a look.

→ Find more [component playgrounds for React](https://blog.bitsrc.io/11-react-ui-component-playgrounds-for-2018-eef5a87a1bf8):
[**11 React UI Component Playgrounds for 2019**
*Useful online playgrounds and editors for your UI components*blog.bitsrc.io](https://blog.bitsrc.io/11-react-ui-component-playgrounds-for-2018-eef5a87a1bf8)

* Also see: [react-cosmos](https://github.com/react-cosmos/react-cosmos) | [react-live](https://github.com/FormidableLabs/react-live)

## 4. Docz

![Docz](https://cdn-images-1.medium.com/max/3504/1*rDykaPREeCndAiNSnFuCJA.png)*Docz*

[Docz](https://www.docz.site/docs/introduction) makes it easier to build Gtabsy-powered documentation websites for your code. It’s based on MDX (*Markdown + JSX) *to leverage markdown for component documentation. Basically, you can write an .mdx file anywhere in your project and Docz will streamline the process of turning it into a documentation portal of your own design deployed to Netlify. Useful right?
[**pedronauck/docz**
*✍🏻It has never been so easy to document your things! - pedronauck/docz*github.com](https://github.com/pedronauck/docz)

## 5. MDX-docs

![MDX-docs](https://cdn-images-1.medium.com/max/2880/1*0z5xTLkduZ1nOW0G78pU9g.gif)*MDX-docs*

[MDX-docs](https://github.com/jxnblk/mdx-docs) lets you document and develop React components with MDX and Next.js. You can mix markdown with inline JSX to render React components. Write markdown as you normally would and use ES import syntax to use custom components in your document. Built-in components render JSX fenced code blocks as live previews with editable code, powered by [react-live](https://github.com/FormidableLabs/react-live).

Take a look.
[**jxnblk/mdx-docs**
*memo: Document and develop React components with MDX and Next.js - jxnblk/mdx-docs*github.com](https://github.com/jxnblk/mdx-docs)

## 6. React Docgen

![](https://cdn-images-1.medium.com/max/2860/1*YcmXrKZtgXzHBciYcWJTKQ.png)

[React DocGen](https://github.com/reactjs/react-docgen) is a CLI and toolbox to extract information from React component files for documentation generation purposes. It uses [ast-types](https://github.com/benjamn/ast-types) and [@babel/parser](https://github.com/babel/babel/tree/master/packages/babel-parser) to parse the source into an AST and provides methods to process this AST to extract the desired information. The output / return value is a JSON blob / JavaScript object. It provides a default implementation for React components defined via React.createClass, [ES2015 class definitions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) or functions (stateless components). Functional and powerful.
[**reactjs/react-docgen**
*A CLI and toolbox to extract information from React component files for documentation generation purposes. …*github.com](https://github.com/reactjs/react-docgen)