Set up Storybook for an Expo React Native project, including Expo Router projects.
Standard baseline for Expo React Native projects, including Expo Router.
npx expo install for native Expo dependencies.expo start -c..rnstorybook/storybook.requires.ts when stories or addons drift.npx storybook@latest init
npm install --save-dev cross-env
npx expo install expo-constants
Use app.config.js to expose Storybook mode:
export default ({ config }) => ({
...config,
extra: {
...config.extra,
storybookEnabled: process.env.STORYBOOK_ENABLED === 'true',
},
});
Gate Storybook from app/_layout.tsx and return Storybook when the flag is enabled.
{
"scripts": {
"storybook": "cross-env STORYBOOK_ENABLED='true' expo start",
"storybook:clear": "cross-env STORYBOOK_ENABLED='true' expo start -c",
"storybook:generate": "sb-rn-get-stories"
}
}
Create one simple story when the repo has none.
expo install, then rebuild the dev app.