Storybook is a widely adopted open-source tool for developing, documenting, and testing UI components in isolation. It enables developers to create "stories" that represent different states of a component, facilitating visual testing, collaboration, and automated testing. The current stable version is 10.3.5, with major releases roughly once a year and minor releases every eight weeks, preceded by alpha/beta/rc pre-releases. Key differentiators include its extensive addon ecosystem, cross-framework support (React, Vue, Angular, etc.), and emphasis on Component Story Format (CSF) for portable story definitions. It's an essential tool for building and maintaining robust design systems, providing a dedicated environment to explore and showcase component variations.
npm install storybookVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a React component and its stories using TypeScript and Component Story Format (CSF) 3. It showcases basic props, argTypes for control customization, and multiple story variants.
Migrate your `.storybook` configuration files to ESM syntax (e.g., `export default { ... }` instead of `module.exports = { ... }`). Ensure your `package.json` specifies `"type": "module"` if all files are ESM, or use `.mjs` extensions for ESM files alongside CJS. Storybook provides an automigration command: `npx storybook@latest upgrade`.Upgrade your Node.js environment to version 20.19+ or 22.12+. Use a Node Version Manager (nvm, volta) to manage multiple Node.js versions.
If using `@storybook/addon-mcp`, ensure you upgrade it to version `>=0.5.0` to re-enable component manifests. The `@storybook/addon-mcp` package specifically re-enables this functionality.
Rewrite your stories from the `storiesOf(...).add(...)` chain to the object-based `export default meta; export const MyStory: Story = { args: {...} };` format. This provides better type safety and compatibility with modern Storybook features.Update your `metro.config.js` to use a named import: `const { withStorybook } = require('@storybook/react-native/metro/withStorybook');` instead of `const withStorybook = require('@storybook/react-native/metro/withStorybook');`.Ensure your `.storybook` folder and its configuration files (especially `main.ts` or `main.js`) have correct relative paths and explicit file extensions for imports. Check for duplicate Storybook packages or version mismatches in your `node_modules` and `package.json`. Running `npx storybook@latest upgrade --force` and `npm install` can sometimes resolve underlying dependency issues.
Delete your `node_modules` folder and `package-lock.json` (or `yarn.lock`), then reinstall dependencies (`npm install` or `yarn install`). Verify that your Babel configuration (if customized) is compatible with Storybook's version. You can debug Webpack configuration with `storybook dev --debug-webpack`.
Use TypeScript utility types like `Omit` or `Partial` when defining the `Meta` type for your Angular components to exclude `EventEmitter` properties or make them optional. Define a helper function to prepare arguments, ensuring only compatible properties are passed to Storybook.
Add explicit `.js` or `.ts` (or `.mjs`, `.mts`) extensions to all relative imports in your `.storybook/main` file. For example, change `import sharedMain from '../main'` to `import sharedMain from '../main.js'` or `../main.ts`.