Storybook main.js Generator
Generate the .storybook/main.js for Storybook 7+ with React and Vite, ready to use. Copy the config and start documenting your components in minutes.
Storybook main.js for React and Vite
You already have a React project on Vite and just want to slot Storybook into it. Running the init sometimes rewrites more than you would like, or fails because your folder layout is not the standard one. In practice, what you are missing is a single file: the .storybook/main.js that points at your stories and names the framework.
The tool prints that file whole, with no fields to fill in, visible the moment the page opens. It uses module.exports to declare a stories glob under ../src covering js, jsx, ts, tsx and mdx, an addons list with essentials, interactions and links, the @storybook/react-vite framework, and docs with autodocs in tag mode. The path is relative to the .storybook folder, not to the project root.
Two edits come up often. Since the file uses module.exports, it breaks when package.json has type: module; rename it to main.cjs or switch to export default. And this is a Storybook 7 shaped config: newer releases folded much of the essentials bundle into the core, so check which addon packages you still need before installing all three. The text is generated in your browser.
Frequently asked questions
Does it work with Next.js or Vue?
My stories do not show up. Why?
Where is preview.js?
Related Tools
netlify.toml Generator
Generate a netlify.toml with build command, redirects and security headers ready for your Netlify deploy. Set it up in the browser and copy the file.
Rollup Config Generator
Generates a rollup.config.js to bundle libraries as ESM and CommonJS, with the node-resolve, commonjs and terser plugins already wired. A fixed block, ready to tweak.
Webpack Config Generator
Generate a minimal webpack.config.js.