Skip to content

feat(storybook): compose React Native components into React Storybook#1188

Merged
georgewrmarshall merged 2 commits into
mainfrom
feat/storybook-composition
Jun 9, 2026
Merged

feat(storybook): compose React Native components into React Storybook#1188
georgewrmarshall merged 2 commits into
mainfrom
feat/storybook-composition

Conversation

@georgewrmarshall

@georgewrmarshall georgewrmarshall commented May 25, 2026

Copy link
Copy Markdown
Contributor

Description

Adds React Native component stories to the existing React Storybook by using Storybook composition.

The React Storybook now acts as the host Storybook and includes a composed React Native Components section. This makes the React Native web Storybook available from the same Storybook UI in local development, PR preview builds, and the deployed web Storybook.

Storybook composition lets one Storybook reference another Storybook by URL so stories from both appear together in the sidebar, even when they use different renderers or project setup: https://storybook.js.org/docs/sharing/storybook-composition

What changed

  • Adds a react-native Storybook refs entry in apps/storybook-react/.storybook/main.ts.
  • Points the composed React Native Storybook to http://localhost:6007 during local development.
  • Points the composed React Native Storybook to ./react-native for static hosted builds.
  • Updates the main Storybook workflow to build the React Storybook and React Native web Storybook, then nest the React Native static build under storybook-static/react-native/ before deploying to GitHub Pages.
  • Updates the PR Storybook workflow to do the same nesting before uploading PR preview builds, so React Native component stories are available in PR builds too.

Local dev workflow

# Terminal 1
yarn storybook:web

# Terminal 2
yarn storybook

Open http://localhost:6006 and expand React Native Components in the sidebar.

Related issues

Depends on: #1134

Manual testing steps

  1. Start yarn storybook:web and wait for the React Native web Storybook to run on port 6007.
  2. Start yarn storybook and open http://localhost:6006.
  3. Confirm React Native Components appears in the sidebar.
  4. Expand React Native Components and open a story.
  5. Confirm the story renders in the main canvas.
  6. Open the PR Storybook preview build.
  7. Confirm React Native Components is available there as well.

Screenshots/Recordings

After

The hosted React Storybook includes a composed React Native Components section backed by the React Native web Storybook.

after720.mov

Pre-merge author checklist

  • I've followed MetaMask Contributor Docs
  • I've completed the PR template to the best of my ability
  • I've included tests if applicable
  • I've documented my code using JSDoc format if applicable
  • I've applied the right labels on the PR

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Low Risk
Changes are limited to Storybook config and GitHub Actions; no runtime product or package publish paths are affected.

Overview
Wires Storybook composition so the React Storybook hosts React Native web stories in one sidebar (React Native Components).

apps/storybook-react/.storybook/main.ts adds a refs.react-native entry whose URL is http://localhost:6007 in dev (overridable via STORYBOOK_RN_URL) and ./react-native for static builds.

Main and PR Storybook workflows no longer use a single default working directory for all steps. They build React Storybook and React Native web Storybook separately, copy the RN static output into storybook-static/react-native/, then deploy or upload the combined apps/storybook-react/storybook-static artifact unchanged for consumers.

Reviewed by Cursor Bugbot for commit e52bd25. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Absolute refs URL breaks on sub-path deployments
    • Updated the Storybook refs URL from '/react-native' to './react-native' so composition works under sub-path hosting (e.g., GitHub Pages and PR previews).

Create PR

Or push these changes by commenting:

@cursor push d23ee11abb
Preview (d23ee11abb)
diff --git a/apps/storybook-react/.storybook/main.ts b/apps/storybook-react/.storybook/main.ts
--- a/apps/storybook-react/.storybook/main.ts
+++ b/apps/storybook-react/.storybook/main.ts
@@ -24,7 +24,7 @@
 // In production the RN static build is nested at /react-native on the same host.
 const rnStorybookUrl =
   process.env.STORYBOOK_RN_URL ??
-  (process.env.NODE_ENV === 'production' ? '/react-native' : 'http://localhost:6007');
+  (process.env.NODE_ENV === 'production' ? './react-native' : 'http://localhost:6007');
 
 const config: StorybookConfig = {
   refs: {

You can send follow-ups to the cloud agent here.

Comment thread apps/storybook-react/.storybook/main.ts Outdated
@georgewrmarshall georgewrmarshall changed the title feat(storybook): compose React Native Storybook into React Storybook for unified hosting chore(storybook): compose React Native Storybook into React Storybook for unified hosting May 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: CommonJS include option restricts processing to one package
    • Added /node_modules/ to commonjsOptions.include so all CJS deps are processed while still explicitly handling react-native-jazzicon.

Create PR

Or push these changes by commenting:

@cursor push a8c49d4954
Preview (a8c49d4954)
diff --git a/apps/storybook-react-native/.storybook/main.ts b/apps/storybook-react-native/.storybook/main.ts
--- a/apps/storybook-react-native/.storybook/main.ts
+++ b/apps/storybook-react-native/.storybook/main.ts
@@ -74,7 +74,7 @@
         commonjsOptions: {
           // Explicitly include CJS-only packages so Rollup's commonjs plugin
           // converts them to ESM in the production bundle.
-          include: [/react-native-jazzicon/],
+          include: [/react-native-jazzicon/, /node_modules/],
           transformMixedEsModules: true,
         },
       },

You can send follow-ups to the cloud agent here.

Comment thread apps/storybook-react-native/.storybook/main.ts
@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

// in both dev and production builds.
include: [
...(viteConfig.optimizeDeps?.include ?? []),
'react-native-jazzicon',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 89c30ab. The build.commonjsOptions.include pattern was removed entirely — setting include on @rollup/plugin-commonjs restricts the plugin to only the matched packages, silently skipping CJS→ESM conversion for every other CJS dependency in the production bundle. The default (no include filter) processes all CJS files, which is correct. CJS conversion for react-native-jazzicon in the dev server is handled by optimizeDeps.include; Rollup's default commonjs pass covers production builds.

@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@georgewrmarshall georgewrmarshall force-pushed the codex/storybook-react-native-backgrounds branch 2 times, most recently from 9e2aaaf to f4a33d5 Compare June 3, 2026 20:54
Base automatically changed from codex/storybook-react-native-backgrounds to main June 5, 2026 16:09
@georgewrmarshall georgewrmarshall force-pushed the feat/storybook-composition branch from 89c30ab to 5786484 Compare June 7, 2026 01:43
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Production ref URL mis-resolved
    • Configured the host Storybook build steps to export STORYBOOK_RN_URL=./react-native so the composed ref resolves to the production path during static builds.

Create PR

Or push these changes by commenting:

@cursor push 66cfe4ea3f
Preview (66cfe4ea3f)
diff --git a/.github/workflows/build-storybook-main.yml b/.github/workflows/build-storybook-main.yml
--- a/.github/workflows/build-storybook-main.yml
+++ b/.github/workflows/build-storybook-main.yml
@@ -21,6 +21,8 @@
 
       - name: Build React Storybook
         working-directory: apps/storybook-react
+        env:
+          STORYBOOK_RN_URL: ./react-native
         run: |
           yarn build-storybook
           touch storybook-static/.nojekyll

diff --git a/.github/workflows/build-storybook-pr.yml b/.github/workflows/build-storybook-pr.yml
--- a/.github/workflows/build-storybook-pr.yml
+++ b/.github/workflows/build-storybook-pr.yml
@@ -23,6 +23,8 @@
 
       - name: Build React Storybook
         working-directory: apps/storybook-react
+        env:
+          STORYBOOK_RN_URL: ./react-native
         run: yarn build-storybook
 
       - name: Build React Native web Storybook

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 5786484. Configure here.

Comment thread apps/storybook-react/.storybook/main.ts
@georgewrmarshall georgewrmarshall changed the title chore(storybook): compose React Native Storybook into React Storybook for unified hosting feat(storybook): compose React Native components into React Storybook Jun 8, 2026
@georgewrmarshall georgewrmarshall marked this pull request as ready for review June 8, 2026 16:43
@georgewrmarshall georgewrmarshall requested a review from a team as a code owner June 8, 2026 16:43
@georgewrmarshall georgewrmarshall enabled auto-merge (squash) June 8, 2026 18:04
@georgewrmarshall georgewrmarshall self-assigned this Jun 8, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@georgewrmarshall georgewrmarshall merged commit dac09b5 into main Jun 9, 2026
36 checks passed
@georgewrmarshall georgewrmarshall deleted the feat/storybook-composition branch June 9, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants