Standalone Options

There is also an API for running Storybook from Node.

  1. const storybook = require('@storybook/{APP}/standalone');
  2. storybook({
  3. // options
  4. });

Where the APP is one of the supported apps. For example:

  1. const storybook = require('@storybook/react/standalone');
  2. storybook({
  3. // options
  4. });

Mode

Mode is defining what Storybook mode will be applied:

dev

run Storybook in a dev mode - similar to start-storybook in CLI

  1. const storybook = require('@storybook/react/standalone');
  2. storybook({
  3. mode: 'dev',
  4. // other options
  5. });

static

build static version of Storybook - similar to build-storybook in CLI

  1. const storybook = require('@storybook/react/standalone');
  2. storybook({
  3. mode: 'static',
  4. // other options
  5. });

Other options are similar to those in the CLI.

For “dev” mode:

  1. port [number] Port to run Storybook
  2. host [string] Host to run Storybook
  3. staticDir <dir-names> Directory where to load static files from, array of strings
  4. configDir [dir-name] Directory where to load Storybook configurations from
  5. https Serve Storybook over HTTPS. Note: You must provide your own certificate information.
  6. sslCa <ca> Provide an SSL certificate authority. (Optional with "https", required if using a self-signed certificate)
  7. sslCert <cert> Provide an SSL certificate. (Required with "https")
  8. sslKey <key> Provide an SSL key. (Required with "https")
  9. smokeTest Exit after successful start
  10. ci CI mode (skip interactive prompts, don't open browser)
  11. quiet Suppress verbose build output

For “static” mode:

  1. staticDir <dir-names> Directory where to load static files from, array of strings
  2. outputDir [dir-name] Directory where to store built files
  3. configDir [dir-name] Directory where to load Storybook configurations from
  4. watch Enable watch mode
  5. quiet Suppress verbose build output

Example:

  1. const storybook = require('@storybook/angular/standalone');
  2. storybook({
  3. mode: 'dev',
  4. port: 9009,
  5. configDir: './.storybook',
  6. });