— 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.

@vitus-labs/tools-storybookv2.9.1 · MIT
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.

01

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.

02

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.

03

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.

04

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.

beforeHand-written .storybook/
.storybook/main.ts · manager.ts
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.

after@vitus-labs/tools-storybook
vl-tools.config.mjs · package.json
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 /docs by default

  • vl_stories-monorepo

    and its -build twin read stories from packages/*/src

  • autoDiscovery

    opt-in generated stories for components that have no stories of their own

  • rocketstories

    point generated stories at your own wrapper module and export

  • addons

    a11y, chromatic, designs, docs, dark mode, pseudo-states, themes and vitest; false drops one

  • backgrounds

    light and dark presets with an 8px grid; default maps to Storybook 10's global

  • ui.theme

    dark or light for 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, /preview and /manager for 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_stories commands don't read it. Move the settings into vl-tools.config.mjs, or run Storybook's own CLI and re-export the presets from your .storybook files.

  • 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-vite and @storybook/nextjs-vite, with react >= 19 as 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.

01

One Storybook for a whole monorepo

Run from the root. Stories come from packages/*/src, and with discovery on, so do component index files.

package.json (root)
{
  "scripts": {
    "stories": "vl_stories-monorepo",
    "stories:build": "vl_stories-monorepo-build"
  }
}
02

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.

vl-tools.config.mjs
export default {
  stories: {
    autoDiscovery: true,
    rocketstories: {
      module: '@acme/ui/stories',
      export: 'storyOf',
    },
  },
}
03

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.

vl-tools.config.mjs
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-storybook
Sources · 33 claims, each traced to v2.9.1 code or docs
  1. Four CLI commandstools:packages/storybook/package.json
  2. CLI runs Storybook with the package's own config directorytools:packages/storybook/src/storybook/index.ts
  3. .storybook/ in the project is not read by vl_stories; configure via vl-tools.config.mjstools:packages/storybook/README.md
  4. Config key stories in vl-tools.config.mjstools:packages/storybook/src/config/index.ts
  5. Defaults: port 6006, outDir /docs, framework vite, ui.theme darktools:packages/storybook/src/config/baseConfig.ts
  6. Monorepo stories from packages/*/srctools:packages/storybook/src/config/baseConfig.ts
  7. autoDiscovery is opt-in and adds index globstools:packages/storybook/src/config/baseConfig.ts
  8. Rocketstyle components get Default, per-dimension and PseudoStates storiestools:packages/storybook/src/indexer/index.ts
  9. A sibling *.stories.* file or one in __stories__/ counts as manual storiestools:packages/storybook/src/indexer/utils.ts
  10. Components with manual stories are skipped by discoverytools:packages/storybook/src/indexer/index.ts
  11. Plain React components get a basic Default storytools:packages/storybook/src/vite-plugin/index.ts
  12. CSF indexer cannot parse `export default stories.init()`; custom indexer delegates the resttools:packages/storybook/src/storybook/main.ts
  13. Eight external addons mapped (a11y, chromatic, designs, docs, dark mode, pseudo-states, themes, vitest)tools:packages/storybook/src/storybook/main.ts
  14. Essentials are built into Storybook 10 coretools:packages/storybook/src/storybook/main.ts
  15. Addon set to a falsy value is droppedtools:packages/storybook/src/storybook/main.ts
  16. next → @storybook/nextjs-vite, otherwise react-vitetools:packages/storybook/src/storybook/main.ts
  17. next/font mocked during dependency pre-bundlingtools:packages/storybook/src/storybook/main.ts
  18. react-native aliases react-native-web and prefers .native.*; web prefers .web.*tools:packages/storybook/src/storybook/main.ts
  19. Platform globals defined for storiestools:packages/storybook/src/storybook/main.ts
  20. tsconfig paths resolved via vite-tsconfig-pathstools:packages/storybook/src/storybook/main.ts
  21. ui.theme drives the manager themetools:packages/storybook/src/storybook/manager.ts
  22. backgrounds.default mapped to Storybook 10 global; light/dark presets, 8px gridtools:packages/storybook/src/storybook/preview.ts
  23. Grid cell size 8tools:packages/storybook/src/config/baseConfig.ts
  24. All stories tagged autodocs; Next.js appDirectory parametertools:packages/storybook/src/storybook/preview.ts
  25. Object-valued addon settings passed as preview parameterstools:packages/storybook/src/storybook/preview.ts
  26. Preset subpath exports main / preview / manager; manager is a side-effect moduletools:packages/storybook/README.md
  27. Rocketstyle detection is a loose text heuristic; give a plain component a manual story to opt outtools:packages/storybook/README.md
  28. Rocketstyle detection is a regex over source texttools:packages/storybook/src/indexer/utils.ts
  29. Generated stories import the component's default exporttools:packages/storybook/src/vite-plugin/index.ts
  30. rocketstories module configurable (module, export); not a dependencytools:packages/storybook/README.md
  31. Peers react >= 19, react-dom >= 19tools:packages/storybook/package.json
  32. Storybook 10, Vite and addons are regular dependenciestools:packages/storybook/package.json
  33. UI system packages run vl_stories as their dev scriptui-system:packages/attrs/package.json