# Add Storybook to an Expo App

Yes. An agent installs Storybook for React Native, wires it into Metro and the entry behind an env flag, writes stories per component, keeps checks green, in a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-storybook/expo/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads the app before it adds a tool. In a project like infinitered/ignite's `boilerplate/`, `package.json` runs on Expo 55 and React Native 0.83 with `expo start --dev-client`, `expo run:ios`, `expo start --web`, `compile` as `tsc --noEmit`, `lint` as `eslint . --fix` and `test` as `jest`; the devDependencies hold `jest-expo`, `@testing-library/react-native`, `prettier` and the Reactotron packages, and nothing named Storybook. `app.json` names the app `HelloWorld` with the `helloworld` scheme and `newArchEnabled` on, `index.tsx` at the root is the entry, and `metro.config.js` wraps `getDefaultConfig` with `inlineRequires: true` and a `cjs` source extension. `tsconfig.json` maps `@/*` to `./app/*`. The components in `app/components/` are `Button`, `Text`, `TextField`, `Card`, `ListItem`, `Header`, `Icon`, `AutoImage`, `EmptyState`, `Screen` and the `Toggle` family; `Text.test.tsx` shows a component must render inside `ThemeProvider` from `app/theme/context` and a `NavigationContainer`. `app/screens/DemoShowroomScreen/demos/` already demonstrates each component in a scrolling screen, which is the list of states the stories should cover.

It installs the on-device Storybook and keeps the app's entry intact. `@storybook/react-native` and its addons go into devDependencies, a `.rnstorybook/` directory gets `main.ts` pointing at `app/**/*.stories.tsx`, a `preview.tsx` with a decorator that wraps every story in `ThemeProvider` and `NavigationContainer` as the existing test does, and the generated `storybook.requires.ts` that the Storybook CLI writes. `metro.config.js` is wrapped with Storybook's `withStorybook` helper, which turns the story list on only when `EXPO_PUBLIC_STORYBOOK_ENABLED` is set, so the production bundle never includes stories. `index.tsx` checks that same variable and registers the Storybook root instead of `App` when it is on; two scripts, `storybook:ios` and `storybook:android`, set the variable and start Expo.

Stories come from the showroom, not from scratch. For each demo file the agent writes a `*.stories.tsx` beside the component with one story per state the demo shows: `Button` presets and accessories, `Text` presets and sizes, `TextField` with helper and error, each `Toggle` variant, `Card` with and without footer, `ListItem` with left and right icons. Controls use the component's own prop types so a designer can flip a preset without code, and the `tx` props that look up i18n keys are given plain `text` in stories so the strings render without a locale switch. The showroom screen stays; the stories reference it in a comment so the two do not drift apart silently.

Then it checks what it can in a sandbox without a simulator. It runs `yarn compile` so the story files and the decorator type-check against the `@/*` paths, `yarn lint` under the Expo ESLint config, and `yarn test` to show the existing Jest setup still passes with the new devDependencies installed. It runs the Storybook CLI's story collection once so `storybook.requires.ts` matches the files on disk, and starts Metro with the flag on to confirm the bundle resolves the Storybook entry before opening the pull request.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add Storybook for React Native to this Expo app. Read package.json, app.json, app.config.ts, index.tsx, metro.config.js, babel.config.js, tsconfig.json, jest.config.js, test/setup.ts, app/components/Text.test.tsx, every file in app/components and every file in app/screens/DemoShowroomScreen/demos first. Install @storybook/react-native and its addons as devDependencies, create .rnstorybook with main.ts, preview.tsx and the generated storybook.requires.ts, and add a decorator that wraps stories in ThemeProvider and NavigationContainer as Text.test.tsx does. Wrap metro.config.js with withStorybook so stories are included only when EXPO_PUBLIC_STORYBOOK_ENABLED is set, and make index.tsx register the Storybook root instead of App under that flag. Add storybook:ios and storybook:android scripts. Write one stories file per component with a story for each state the showroom demos show, using plain text instead of tx keys. Run yarn compile, yarn lint and yarn test, regenerate the story list, and start Metro once with the flag on to confirm the entry resolves. Open a pull request that lists each component, its stories and the flag that keeps Storybook out of production.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request that adds `.rnstorybook/main.ts`, `.rnstorybook/preview.tsx` and `.rnstorybook/storybook.requires.ts`, a `*.stories.tsx` beside each component in `app/components/`, edits `metro.config.js`, `index.tsx` and `package.json`, and updates the lockfile. The description lists each component with the names of its stories, says which env variable turns Storybook on, and states that the production bundle is unchanged when the variable is unset.

The run's record keeps the `tsc`, ESLint and Jest output and the Metro start log with the flag on, so a reviewer can see the stories type-check against the `@/*` paths and that Metro resolved the Storybook entry, without pulling the branch first.

Before merging, a reviewer runs `yarn storybook:ios` on a simulator, opens three or four stories including a `Toggle` and a `TextField` with an error, and confirms `yarn ios` without the flag still boots the app to the welcome screen.

## Run it on every component library that only exists as a demo screen

The setup is one `POST /o/{org}/sessions` with this body and the repository in `resources`, started from a terminal; the run keeps going in its sandbox after the window closes, and a follow-up through `POST /o/{org}/sessions/{id}/messages` can ask for the web Storybook as well or for stories of a screen rather than a component, without starting over. A team with several Expo apps sends one request per repository, each with its own UUID as `request_id`, so a rerun of the script returns the run it already started.

Give the API key a `webhook_url` and Rush POSTs `run.completed` or `run.failed` when a run's turn finishes, with `session_url` so your server can read the pull request link and the test output.

## Why run it on Rush?

Adding Storybook to an Expo app is mostly plumbing that fails late: a Metro config that includes stories in the release bundle, a story that renders outside the theme provider and crashes on the first `useAppTheme`, a generated requires file that goes stale after the first new component. The agent reads the existing test's provider setup, wires the flag into Metro and the entry, and runs the project's own `tsc`, lint and Jest in its sandbox to catch those before a reviewer opens a simulator.

The commands and their output stay with the run, so the pull request can point at the Metro log that resolved the Storybook entry and at the Jest run that still passed with the new devDependencies, and a reviewer only has to tap through a few stories on a device.

## Frequently asked questions

### Will Storybook end up in my production build?

No. Metro includes the story list only when `EXPO_PUBLIC_STORYBOOK_ENABLED` is set, and `index.tsx` registers `App` unless that variable is on. An EAS build without the variable produces the same bundle as before.

### Why wrap stories in ThemeProvider and NavigationContainer?

The components read the theme through `useAppTheme`, and `Text.test.tsx` already shows they must render under `ThemeProvider` inside a `NavigationContainer`. A global decorator in `preview.tsx` does that once for every story.

### Does this replace the DemoShowroomScreen?

No. The showroom stays as the in-app gallery, and the agent derives each story's states from its demo files so the two match. Storybook adds controls and isolated rendering; the showroom remains the quickest way to see everything at once in the running app.

### Can the stories run on the web too?

The on-device Storybook runs inside the Expo app on iOS, Android and, since the project has a `web` script, in the browser through React Native Web. A separate web Storybook build is a follow-up the pull request mentions, not something the agent adds unasked.

## More Expo jobs

- [Add TanStack Query to an Expo App](https://getrush.ai/run/add-tanstack-query/expo/)
- [Add Universal Links to an Expo App](https://getrush.ai/run/add-universal-links/expo/)
- [Migrate an Expo Project from Jest to Vitest](https://getrush.ai/run/migrate-jest-to-vitest/expo/)

## The same job on other stacks

- [Set Up Storybook for Lit Web Components](https://getrush.ai/run/add-storybook/lit/)
- [Add Storybook to a SolidJS App](https://getrush.ai/run/add-storybook/solidjs/)

## More jobs like this: Hand off a long task

- [Add Streaming Responses to a Hono API](https://getrush.ai/run/add-streaming-responses/hono/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
