withStorybook() function to customize Storybook’s Metro integration.
Interface
Options
The path to the Storybook config folder. This is where your
main.js/ts and preview.js/ts files are located.If
false, attempts to remove Storybook modules from the JavaScript bundle to reduce bundle size.When true, enables Storybook metro configuration and generates the storybook.requires file. When false, removes all Storybook code from the bundle by replacing imports with empty modules.Useful for conditionally including Storybook in development but excluding it from production builds:Whether to use JavaScript files for Storybook configuration instead of TypeScript.When
true, generates storybook.requires.js instead of storybook.requires.ts.Whether to include doc tools in the
storybook.requires file.Doc tools provide additional documentation features and work with babel-plugin-react-docgen-typescript.Whether to use lite mode for Storybook.In lite mode, the default Storybook UI is mocked out so you don’t need to install all its dependencies like
react-native-reanimated. This is useful for reducing bundle size and dependencies.Use this when using @storybook/react-native-ui-lite instead of @storybook/react-native-ui.WebSocket configuration for syncing Storybook instances or sending events to Storybook.When provided, creates a WebSocket server for real-time communication. This allows you to sync up multiple devices to show the same story and arg values.Use
'auto' to automatically detect your LAN IP and inject host/port into the generated storybook.requires file.See WebSocket Options below for detailed configuration.Whether to enable MCP (Model Context Protocol) server support.When enabled, adds an
/mcp endpoint to the channel server, allowing AI agents (Claude Code, Cursor, etc.) to query component documentation.If websockets are disabled, MCP documentation tools still work but story selection is unavailable.Available from v10.3 onwards.WebSocket Options
The port WebSocket server will listen on.
The host WebSocket server will bind to.When using
'auto' for the websockets option, the host is automatically detected and set to undefined (allowing connections from any interface).Examples
Minimal Configuration
Full Configuration
Production Build (Disabled)
Lite Mode (Reduced Dependencies)
Related
- withStorybook() - Main Metro wrapper function
- Getting Started - Setup guide