Framework Integration
Storybook Astro supports rendering components from React, Vue, Svelte, Preact, Solid, and Alpine.js alongside native Astro components. Each framework is handled by an integration adapter.
Integration architecture
Section titled “Integration architecture”Each integration extends the BaseIntegration class and implements four methods:
getAstroRenderer()— Returns the Astro framework integration (e.g.@astrojs/react)getVitePlugins()— Returns Vite plugins needed for the framework (e.g.@vitejs/plugin-react)getStorybookRenderer()— Returns the Storybook renderer name (e.g.@storybook/react)resolveClient(specifier)— Handles client-side module resolution if needed
Integration files live in packages/@storybook-astro/framework/src/integrations/.
The include pattern
Section titled “The include pattern”Most integrations accept an include option — a glob pattern that tells Vite which files to process with the framework’s compiler:
react({ include: ['**/react/**'] })solid({ include: ['**/solid/**'] })How delegation works
Section titled “How delegation works”When a story sets parameters.renderer, the render pipeline changes:
- The renderer (
render.tsx) checksparameters.rendereron the story - Instead of routing through the Astro Container API, it delegates to the specified framework’s
renderToCanvasfunction - The framework renderer manages its own reactive root and lifecycle
storyFn()is called after delegation — this ordering is critical for frameworks like Solid that manage their own reactive roots
Virtual modules
Section titled “Virtual modules”The framework integration system uses two virtual modules:
virtual:astro-container-renderers— Provides anaddRenderersfunction to register framework renderers with the Astro Containervirtual:storybook-renderer-fallback— Provides framework renderers for client-side delegation
Adding a new framework
Section titled “Adding a new framework”To add a new framework integration:
- Create an integration file in
packages/@storybook-astro/framework/src/integrations/ - Extend
BaseIntegrationand implement the required methods - Export a factory function in
integrations/index.ts - Install the corresponding Astro integration, Vite plugin, and Storybook renderer packages
See the existing integrations (e.g. react.ts, vue.ts) for reference implementations.