Getting started with the Command Line Interface (CLI)
The CLI can be used directly, installed globally, or installed in any project as a dependency.
In order to use it directly any of these commands will work:
npx @react-docgen/cli --help
Installing the CLI can be done with any available package manager:
npm install --save @react-docgen/cli
For basic usage, you need to provide a glob or path to a file that includes a
react component. The result will be printed to the
stdout and in case there
are errors or warnings while analyzing the file, these will be printed to
The result will be an array of Documentation objects, stringified to JSON.
Multiple files can be analyzed at once
react-docgen ./src/components/Button.tsx ./src/components/Label.tsx
Or a glob can be used to include multiple files
The output can be written into a file instead of directly outputting it.
Warnings and errors will still be written to
react-docgen -o output.json ./src/components/Button.tsx
The CLI supports a lot more advanced options and for a full list checkout the reference page