Command-line interface

Brand new

Preview.js CLI came out mid-April 2022.

Feel free to report bugs on GitHub.


Install Preview.js CLI and optionally the Preview.js Pro package:

# pnpm
$ pnpm add -D @previewjs/cli @previewjs/pro

# npm
$ npm install --dev @previewjs/cli @previewjs/pro

# Yarn
$ yarn add -D @previewjs/cli @previewjs/pro

Install the plugin for your framework:

pnpm add -D @previewjs/plugin-react

Finally, create preview.config.js next to your package.json:

// preview.config.js

const { reactFrameworkPlugin } = require("@previewjs/plugin-react");

/** @type {import("@previewjs/config").PreviewConfig} */
module.exports = {
  frameworkPlugin: reactFrameworkPlugin.create(),

You can then run previewjs in your project directory and pick any component to preview!