Skip to content

fix(web): repair web regressions when using expo web support#8924

Open
mikehardy wants to merge 2 commits intomainfrom
@mikehardy/expo-web-fixups
Open

fix(web): repair web regressions when using expo web support#8924
mikehardy wants to merge 2 commits intomainfrom
@mikehardy/expo-web-fixups

Conversation

@mikehardy
Copy link
Collaborator

@mikehardy mikehardy commented Mar 9, 2026

Description

Expo can run react-native-firebase successfully in web mode (npx expo start --web), or at least it used to be able to for most packages.

But there are (or were) two problems:

1- The remote-config package and the AI package have problematic polyfills that touch react-native internals though (specifically, react-native-fetch-api uses an internal react-native Blob import which goes to a native react-native method, and that won't work on web)

2- The auth package uses a method from firebase-js-sdk that is only exposed on the react-native bundle exported for react-native only from firebase-js-sdk package.json

For item 1, I made web specific polyfills that were empty. Metro loads the .web suffix files for the web platform first, so it stubs out the problematic polyfills, while they are still loaded for the native platforms (which includes "other" - where the firebase-js-sdk is running in the react-native environment vs the browser environment)

For item 2, I just check if we are Platform.OS === "web" prior to attempting the react-native-specific method call during auth initialization, and that fixes things.

Related issues

Release Summary

Two fix commits, should generate a semver patch release

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
    • Other (macOS, web)
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan

Extensive use of https://github.com/mikehardy/rnfbdemo/blob/main/make-expo-demo.sh - which I augmented to include a web test for this purpose, and ran against local packages made using .github/workflows/scripts/create_npm_packages.sh packages ~/packages

image

Think react-native-firebase is great? Please consider supporting the project with any of the below:

using the web-targeted firebase-js-sdk implies that we need functioning
implementations of Headers, Request, Response, fetch, and Readable Stream

react-native does not provide those so we polyfill for them whenever we are
using firebase-js-sdk in a native environment and need them

however, Expo can actually use react-native-firebase in a pure web context,
where those things are functioning and need no polyfill - in fact our polyfills
rely on react-native internals and are harmful as they create errors during web
bundling

Expo web uses the metro bundler which allows platform-specific resolution though,
so if we add a no-op polyfills.web file, it is resolved instead of the problematic
polyfills, and everything works
@vercel
Copy link

vercel bot commented Mar 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-native-firebase Error Error Mar 9, 2026 11:30pm

Request Review

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.

[🐛] @react-native-firebase/remote-config web fallback imports RN private modules and crashes Expo web (__fbBatchedBridgeConfig)

2 participants