Skip to content

js: migrate Firebase from v7 (namespaced) to v11 (modular SDK)#408

Merged
jpcottin merged 1 commit into
google:masterfrom
jpcottin:feat/firebase-11-migration
May 16, 2026
Merged

js: migrate Firebase from v7 (namespaced) to v11 (modular SDK)#408
jpcottin merged 1 commit into
google:masterfrom
jpcottin:feat/firebase-11-migration

Conversation

@jpcottin
Copy link
Copy Markdown
Collaborator

Why

The js/ web demo pins firebase 7.19.0 (the last namespaced/legacy v7 release). Firebase v8 deprecated the namespaced API; v9+ ships the tree-shakable modular SDK and v10 dropped the v7 compat shim entirely. Staying on v7 blocks any other dep bump that transitively pulls a newer Firebase, and v7 itself has been EOL for years.

What

Single commit. Migrates js/src/components/login_firebase.js from the v7 namespaced API:

import * as firebase from "firebase/app";
import "firebase/auth";
firebase.initializeApp(config);
firebase.auth().onAuthStateChanged(...)
firebase.auth().signInWithPopup(new firebase.auth.GoogleAuthProvider())

to the v11 modular API:

import { initializeApp } from "firebase/app";
import { getAuth, GoogleAuthProvider, signInWithPopup, onAuthStateChanged } from "firebase/auth";
const app = initializeApp(config);
const auth = getAuth(app);
onAuthStateChanged(auth, ...)
signInWithPopup(auth, new GoogleAuthProvider())

package.json bumps firebase: "^7.19.0""^11.10.0". @react-firebase/auth (deprecated, only used as a v7 helper) is removed — the modular SDK does everything it did and more.

Test plan

Verified end-to-end against a Firebase project I own (not the dead android-emulator-webrtc-demo referenced in the in-repo config — see follow-up note below):

  • npm install && npm start builds clean on react-scripts 5
  • App boots, no v11 init errors in console
  • Google sign-in popup opens, returns a user
  • onAuthStateChanged fires, getIdToken() returns a JWT
  • Token pushed to TokenProviderService.setToken as Bearer <jwt>
  • App transitions to authorized state, renders EmulatorScreen
  • Envoy (per js/develop/envoy.yaml) validates the Firebase JWT against the issuer/audience, proxies gRPC-Web to the emulator container
  • WebRTC video stream from emulator container renders in the browser

Follow-up (separate PR)

The bundled js/firebase_config.json still points at android-emulator-webrtc-demo, which nobody currently has access to. That project has been broken since at least commit 5197542 ("Envoy not recognizing Firebase tokens"). A follow-up PR will restructure the demo to BYO-Firebase: ship a firebase_config.example.json template, fix the (currently no-op) substitution bug in config_gen.py, parameterize the envoy JWT issuer/audience, and document the setup in js/README.md. That's a docs/structural change, kept out of this PR to keep the SDK migration reviewable on its own.

The React web client used `firebase ^7.19.0` (resolving to 7.24.0, last
released 2020-10-26 — 5 years and 4 major versions behind current) and
the deprecated `@react-firebase/auth ^0.2.10` (last released
2019-11-13). The namespaced API the v7 SDK exposes was removed entirely
in v10; @react-firebase/auth does not work against v9+.

Migrate to the v11 modular SDK, drop @react-firebase/auth, and rewrite
the one component that used Firebase (login_firebase.js) to subscribe
to auth state with the native `onAuthStateChanged` hook.

- package.json: firebase ^7.19.0 -> ^11.10.0, remove @react-firebase/auth.
- login_firebase.js: rewritten from a class component using
  `firebase.auth().signInWithPopup(...)` + `<FirebaseAuthProvider>` +
  `<FirebaseAuthConsumer>` to a function component using
  `initializeApp` / `getAuth` / `signInWithPopup` / `onAuthStateChanged`
  from the modular `firebase/app` and `firebase/auth` entry points.
- package-lock.json: regenerated.

Server-side JWT verification (envoy.yaml `firebase_jwt` provider, JWKS
endpoint, issuer/audience) is unchanged — only the client SDK was
swapped. Existing tokens issued by the same Firebase project continue
to validate.

Bundle size: 203.92 KB gzipped (vs 237.96 KB previously). The modular
SDK's tree-shaking removes ~34 KB despite the major version bump.

Unblocks investigation of long-standing webrtc/login issues that were
previously stuck on the obsolete Firebase 7 SDK.
@jpcottin jpcottin merged commit fda013d into google:master May 16, 2026
6 checks passed
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.

1 participant