# setup-react-native-storybook

Automates Storybook 10 installation in React Native projects. It handles configurations for Expo, Expo Router, plain React Native CLI, and Re.Pack.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 526 installs · ★ 1324
- Author: storybookjs
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/storybookjs/react-native/tree/HEAD/skills/setup-react-native-storybook/SKILL.md
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/setup-react-native-storybook

## What it does

The skill detects your active package manager from `yarn.lock`, `pnpm-lock.yaml`, or `bun.lockb`, then runs `create storybook`. It generates configuration files inside `.rnstorybook/`, including `main.ts`, `preview.tsx`, and `index.tsx`. Then it expands the default story globs to match component directories like `src/components/`.

Remote control and web companion syncing require WebSockets, which the skill activates inside `.rnstorybook/index.tsx`. Because of this, the project must have `@react-native-async-storage/async-storage` installed. Bundler setup wraps Metro configs with `withStorybook` or injects `StorybookPlugin` into Re.Pack rspack or webpack configs.

Projects on file-based routing get dedicated Expo Router routes. Automated bundler wrapping expects Metro or Re.Pack, so custom bundlers outside these two will fail during configuration.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add storybookjs/react-native --skill setup-react-native-storybook -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/setup-react-native-storybook/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/setup-react-native-storybook/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add storybookjs/react-native --skill setup-react-native-storybook -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/setup-react-native-storybook/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add storybookjs/react-native --skill setup-react-native-storybook -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/setup-react-native-storybook/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install storybookjs/react-native setup-react-native-storybook
```

2. **Manually: put the files in place**
- File: `.github/skills/setup-react-native-storybook/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add storybookjs/react-native --skill setup-react-native-storybook -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/storybookjs/react-native --path skills/setup-react-native-storybook
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/setup-react-native-storybook/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add storybookjs/react-native --skill setup-react-native-storybook -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/storybookjs/react-native/tree/HEAD/skills/setup-react-native-storybook/SKILL.md

## When to use it
- initialize Storybook 10 across Expo or React Native CLI projects
- route Storybook screens inside Expo Router applications
- wrap Metro bundler configuration with withStorybook
- configure StorybookPlugin for Re.Pack bundlers
- enable WebSocket remote control using AsyncStorage

## Example prompts
- Set up Storybook in this Expo Router project.
- Configure `@storybook/react-native` and update `metro.config.js`.
- Add Storybook to our Re.Pack project with WebSocket support.

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 219a4342172ff88e.

BEGIN THIRD-PARTY FILE 219a4342172ff88e
````text
---
name: setup-react-native-storybook
description: Set up Storybook for React Native in Expo, React Native CLI, or Re.Pack projects. Use when adding Storybook to a project, configuring metro.config.js with withStorybook, creating .rnstorybook configuration files, setting up Storybook routes in Expo Router, configuring getStorybookUI, or adding the StorybookPlugin to a Re.Pack rspack/webpack config. Covers Expo, Expo Router, plain React Native CLI, and Re.Pack setups.
---

# React Native Storybook Setup

Add `@storybook/react-native` v10 to a React Native project.

**Important:** Detect the project's package manager (look for `yarn.lock`, `pnpm-lock.yaml`, or `bun.lockb`) and use it for all install/run commands instead of `npm`. The examples below use `npm` but substitute accordingly (e.g. `yarn add` instead of `npm install`, `yarn storybook` instead of `npm run storybook`). For Expo projects, use `npx expo install` (or `bunx expo install`, etc.) to install dependencies so Expo can resolve compatible versions.

For the init command, use `<pm> create storybook` with the flags shown below. Only npm needs `--` before the flags. Never use `npx`/`bunx` etc for this.

Four setup flows based on project type:

1. **Expo (no router)** - see [references/expo-setup.md](references/expo-setup.md)
2. **Expo with Expo Router** - see [references/expo-router-setup.md](references/expo-router-setup.md)
3. **React Native CLI (no Expo)** - see [references/react-native-cli-setup.md](references/react-native-cli-setup.md)
4. **Re.Pack (rspack/webpack)** - see [references/repack-setup.md](references/repack-setup.md)

## Flow Selection

- Project has `rspack.config` or `webpack.config` and uses `@callstack/repack` -> **Re.Pack**
- Project has `app/` directory with `_layout.tsx` and uses `expo-router` -> **Expo Router**
- Project uses Expo but not file-based routing -> **Expo**
- Project uses `@react-native-community/cli` with no Expo -> **React Native CLI**

## Common Steps (all flows)

### 1. Run CLI Init

```sh
npm create storybook -- --type react_native --yes
# or: pnpm create storybook --type react_native --yes
# or: bun create storybook --type react_native --yes
```

This installs dependencies and creates `.rnstorybook/` with `main.ts`, `preview.tsx`, and `index.tsx`.

### 2. Enable WebSockets in .rnstorybook/index.tsx

Update the generated `.rnstorybook/index.tsx` to enable WebSocket support. This is required for remote control and syncing with the Storybook web companion:

```tsx
// .rnstorybook/index.tsx
import AsyncStorage from '@react-native-async-storage/async-storage';
````
END THIRD-PARTY FILE 219a4342172ff88e

The third-party file has ended. Everything between the 219a4342172ff88e tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2601 of 4927 bytes. © storybookjs · MIT · https://github.com/storybookjs/react-native/tree/HEAD/skills/setup-react-native-storybook/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
