Storybook main.js / .storybook Config Builder

Generate a Storybook configuration for React, Vue, or Angular

Creates .storybook/main.ts and preview.ts files with framework setting, addons (a11y, actions, controls, interactions), static directories, and autodocs configuration for your component library.

What is the difference between main.js and main.ts?

They are the same configuration file in JavaScript versus TypeScript. This tool generates main.ts so you get type-checking via the StorybookConfig type, but you can rename it to main.js and drop the import if you prefer plain JavaScript.

Configure Storybook in seconds

Storybook is an isolated workshop for building and testing UI components, and every project needs a .storybook folder with a main file telling it where stories live, which framework builder to use, and which addons to load. This builder generates a clean, typed main.ts plus a sensible preview.ts so you can scaffold a new Storybook or align an old one with current conventions.

How it works

Storybook reads .storybook/main.ts at startup. The stories array is a glob that Storybook scans to find every *.stories.* file. The framework object selects the compiler and renderer — this is the single most important setting, because it must match your bundler (Vite or Webpack) and UI library (React, Vue, Angular, Svelte). The addons array lists plugins that extend the toolbar and docs.

The generated preview.ts sets global parameters: an actions matcher that auto-detects on* event props, and controls matchers that render color pickers and date pickers based on prop-name patterns. The staticDirs option tells Storybook to serve assets like images or fonts from your public folder, and docs.autodocs: "tag" auto-generates documentation pages.

Tips and notes

  • Install each addon you enable; the config only references the package names.
  • The stories glob is relative to the .storybook folder, so ../src/** points at your source directory.
  • For a TypeScript project keep main.ts; for plain JavaScript rename to main.js and remove the import type line and the StorybookConfig annotation.
  • staticDirs accepts multiple comma-separated paths if you serve assets from more than one folder.