fix(web): repair web regressions when using expo web support#8924
Open
fix(web): repair web regressions when using expo web support#8924
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Shervanator
approved these changes
Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
.websuffix 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
@react-native-firebase/remote-configweb fallback imports RN private modules and crashes Expo web (__fbBatchedBridgeConfig) #8903Release Summary
Two fix commits, should generate a semver patch release
Checklist
AndroidiOSOther(macOS, web)e2etests added or updated inpackages/\*\*/e2ejesttests added or updated inpackages/\*\*/__tests__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 ~/packagesThink
react-native-firebaseis great? Please consider supporting the project with any of the below:React Native FirebaseandInvertaseon Twitter