Main configuration
The main configuration defines a Storybook project's behavior, including the location of stories, addons to use, feature flags, and other project-specific settings.
The main configuration file: main.js or main.ts
This file must be valid ESM. In other words, it must use import instead of require, and neither __dirname nor __filename are available.
This configuration is defined in .storybook/main.js|ts, which is located relative to the root of your project.
A typical Storybook configuration file looks like this:
.storybook/main.ts
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, vue3-vite, etc.
import type { StorybookConfig } from '@storybook/your-framework';
const config: StorybookConfig = {
// Required
framework: '@storybook/your-framework',
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
// Optional
addons: ['@storybook/addon-docs'],
staticDirs: ['../public'],
};
export default config;config
An object to configure Storybook containing the following properties:
framework(Required)stories(Required)addonsbabelbabelDefaultbuildcoredocsenvfeaturesindexers(⚠️ Experimental)logLevelmanagerHeadpreviewAnnotationspreviewBodypreviewHeadrefsstaticDirsswctagstypescriptviteFinalwebpackFinal
