— Tooling · @vitus-labs/tools-storybook
Storybook 10, configured for you.
vl_stories starts Storybook with a config of its own: the framework, a curated addon set, platform globals and an indexer that understands rocketstories files. What you change lives under stories in vl-tools.config.mjs. Turn on autoDiscovery and components without stories get generated ones.
npm i -D @vitus-labs/tools-storybook- CLI commands, single repo and monorepo
- 4
- addons wired in, on top of the built-ins
- 8
- frameworks
- vite · next · RN
— Why tools · storybook
Config you stop maintaining.
No folder to keep in sync
The vl_stories commands point Storybook at the package's own config directory. Framework, addons and Vite setup come from there; your project only sets the options it cares about.
Stories for components that have none
With autoDiscovery, component index files are indexed too. Rocketstyle components get a default story, one per dimension and a pseudo-state grid; plain React components get a default story. A component with its own stories, a sibling *.stories.* file or a __stories__ folder, is left alone.
Rocketstories files index correctly
Storybook's CSF indexer can't statically read export default stories.init. A custom indexer handles those files and hands every other story file to Storybook's own CSF and MDX indexers.
Web, Next.js and React Native
next runs on @storybook/nextjs-vite with next/font mocked during dependency pre-bundling. react-native aliases react-native-web and prefers .native.* files; web builds prefer .web.*.
— Before / after
Three config files, one small object.
A React package with docs, accessibility, theme and Vitest addons, platform globals and a dark manager UI.
import type { StorybookConfig } from '@storybook/react-vite'
const config: StorybookConfig = {
framework: { name: '@storybook/react-vite', options: {} },
stories: ['../src/**/*.stories.@(ts|tsx|mdx)'],
addons: [
'@storybook/addon-docs',
'@storybook/addon-a11y',
'@storybook/addon-themes',
'@storybook/addon-vitest',
'storybook-addon-pseudo-states',
],
viteFinal: async (config) => {
config.define = { ...config.define, __WEB__: 'true', __NATIVE__: 'false' }
return config
},
}
export default config
// .storybook/manager.ts
import { addons } from 'storybook/manager-api'
import { themes } from 'storybook/theming'
addons.setConfig({ theme: themes.dark })
// + .storybook/preview.ts, + "storybook dev -c .storybook"main, preview and manager files per project, each tracking Storybook's config API from release to release.
export default {
stories: {
autoDiscovery: true,
},
}
// package.json
// "stories": "vl_stories",
// "stories:build": "vl_stories-build"Addons, globals and the dark manager are defaults. The config holds only what differs.
— Features
Included, switched on.
- vl_stories · vl_stories-build
dev server on port 6006, static build to
/docsby default - vl_stories-monorepo
and its
-buildtwin read stories frompackages/*/src - autoDiscovery
opt-in generated stories for components that have no stories of their own
- rocketstories
point generated stories at your own wrapper
moduleandexport - addons
a11y, chromatic, designs, docs, dark mode, pseudo-states, themes and vitest;
falsedrops one - backgrounds
light and dark presets with an 8px grid;
defaultmaps to Storybook 10's global - ui.theme
darkorlightfor the manager UI - Platform globals
__BROWSER__,__WEB__,__NATIVE__,__NODE__,__CLIENT__defined for every story - tsconfig paths
path aliases from your tsconfig resolve in stories
- autodocs
every story gets a docs page from the preview tags
- Preset re-exports
storybook/main,/previewand/managerfor Storybook's own CLI
— API
Four commands. Three presets.
Every name links to its reference in the docs.
— Honest limits
When to configure Storybook yourself.
Where it isn't the right fit, and what to reach for instead.
You keep a .storybook folder
The
vl_storiescommands don't read it. Move the settings intovl-tools.config.mjs, or run Storybook's own CLI and re-export the presets from your.storybookfiles.Auto-discovery is a text heuristic
Components are classified with regular expressions over the source: any
.config(,.theme(or.states(call marks a file as rocketstyle, even in a plain React component, and generated stories import its default export. Write a story for a component (a sibling*.stories.*file or one in__stories__/) to opt it out.Not a React project
The frameworks are
@storybook/react-viteand@storybook/nextjs-vite, withreact >= 19as a peer. For Vue, Svelte or React 18, set up Storybook directly.You want a lean install
Storybook 10, Vite and every addon are regular dependencies, installed even when switched off. If install size matters more than setup time, assemble Storybook's packages yourself.
— Recipes
Copy, paste, ship.
One Storybook for a whole monorepo
Run from the root. Stories come from packages/*/src, and with discovery on, so do component index files.
{
"scripts": {
"stories": "vl_stories-monorepo",
"stories:build": "vl_stories-monorepo-build"
}
}Generated stories through your own decorators
Point discovery at a rocketstories wrapper that was created with your theme provider, and every generated story renders inside it. Install the module yourself; it is not a dependency.
export default {
stories: {
autoDiscovery: true,
rocketstories: {
module: '@acme/ui/stories',
export: 'storyOf',
},
},
}A Next.js app with next/font
next switches to the Next.js Vite framework, mocks next/font while dependencies are pre-bundled and sets the App Router flag in preview parameters.
export default {
stories: {
framework: 'next',
port: 6007,
addons: { chromatic: false, designs: false },
ui: { theme: 'light' },
},
}— FAQ
Questions, answered.
Can I still use the storybook CLI?
Yes. Re-export @vitus-labs/tools-storybook/storybook/main and /preview as defaults from your .storybook files, and import /storybook/manager for its side effect: it has no default export.
Do I need rocketstyle or rocketstories?
No. Plain CSF and MDX stories work as usual. Rocketstories is only needed if you use it in stories or let discovery generate stories for rocketstyle components.
Where do addon settings go?
In stories.addons. true or false toggles an addon; objects such as backgrounds, viewport or controls are passed to the preview as parameters.
Who uses it?
The packages of the Vitus Labs UI system run vl_stories as their dev script.
— @vitus-labs/tools-storybook
Write stories, not Storybook config.
npm i -D @vitus-labs/tools-storybookSources · 33 claims, each traced to v2.9.1 code or docs
- Four CLI commandstools:packages/storybook/package.json
- CLI runs Storybook with the package's own config directorytools:packages/storybook/src/storybook/index.ts
- .storybook/ in the project is not read by vl_stories; configure via vl-tools.config.mjstools:packages/storybook/README.md
- Config key stories in vl-tools.config.mjstools:packages/storybook/src/config/index.ts
- Defaults: port 6006, outDir /docs, framework vite, ui.theme darktools:packages/storybook/src/config/baseConfig.ts
- Monorepo stories from packages/*/srctools:packages/storybook/src/config/baseConfig.ts
- autoDiscovery is opt-in and adds index globstools:packages/storybook/src/config/baseConfig.ts
- Rocketstyle components get Default, per-dimension and PseudoStates storiestools:packages/storybook/src/indexer/index.ts
- A sibling *.stories.* file or one in __stories__/ counts as manual storiestools:packages/storybook/src/indexer/utils.ts
- Components with manual stories are skipped by discoverytools:packages/storybook/src/indexer/index.ts
- Plain React components get a basic Default storytools:packages/storybook/src/vite-plugin/index.ts
- CSF indexer cannot parse `export default stories.init()`; custom indexer delegates the resttools:packages/storybook/src/storybook/main.ts
- Eight external addons mapped (a11y, chromatic, designs, docs, dark mode, pseudo-states, themes, vitest)tools:packages/storybook/src/storybook/main.ts
- Essentials are built into Storybook 10 coretools:packages/storybook/src/storybook/main.ts
- Addon set to a falsy value is droppedtools:packages/storybook/src/storybook/main.ts
- next → @storybook/nextjs-vite, otherwise react-vitetools:packages/storybook/src/storybook/main.ts
- next/font mocked during dependency pre-bundlingtools:packages/storybook/src/storybook/main.ts
- react-native aliases react-native-web and prefers .native.*; web prefers .web.*tools:packages/storybook/src/storybook/main.ts
- Platform globals defined for storiestools:packages/storybook/src/storybook/main.ts
- tsconfig paths resolved via vite-tsconfig-pathstools:packages/storybook/src/storybook/main.ts
- ui.theme drives the manager themetools:packages/storybook/src/storybook/manager.ts
- backgrounds.default mapped to Storybook 10 global; light/dark presets, 8px gridtools:packages/storybook/src/storybook/preview.ts
- Grid cell size 8tools:packages/storybook/src/config/baseConfig.ts
- All stories tagged autodocs; Next.js appDirectory parametertools:packages/storybook/src/storybook/preview.ts
- Object-valued addon settings passed as preview parameterstools:packages/storybook/src/storybook/preview.ts
- Preset subpath exports main / preview / manager; manager is a side-effect moduletools:packages/storybook/README.md
- Rocketstyle detection is a loose text heuristic; give a plain component a manual story to opt outtools:packages/storybook/README.md
- Rocketstyle detection is a regex over source texttools:packages/storybook/src/indexer/utils.ts
- Generated stories import the component's default exporttools:packages/storybook/src/vite-plugin/index.ts
- rocketstories module configurable (module, export); not a dependencytools:packages/storybook/README.md
- Peers react >= 19, react-dom >= 19tools:packages/storybook/package.json
- Storybook 10, Vite and addons are regular dependenciestools:packages/storybook/package.json
- UI system packages run vl_stories as their dev scriptui-system:packages/attrs/package.json