Skip to content

[🐞] Firebase Authentication issues in Qwik v2 Beta 11 (works fine in v1) #8108

@wlans

Description

@wlans

Which component is affected?

Qwik Runtime

Describe the bug

Description:
Attempting to use Firebase Authentication in Qwik v2 Beta 11, but it behaves inconsistently and causes errors during build/preview.

In dev mode, onAuthStateChanged only fires for some routes, not all.

When running npm run preview, Firebase throws initialization or runtime errors.

Rolling back to Qwik v1 fixes all of these issues — Firebase auth works normally again.

Steps to Reproduce:

Set up Firebase with Email/Password sign-in enabled.

Add Firebase SDK initialization (e.g. initializeApp, getAuth, onAuthStateChanged).

Run the app using npm run dev and observe inconsistent auth state changes across routes.

Run npm run preview — Firebase complains about missing window or initialization context.

Expected Behavior:
onAuthStateChanged should trigger consistently across all routes, and npm run preview should run without Firebase errors (like it does in Qwik v1).

Actual Behavior:

In dev mode, only some routes trigger onAuthStateChanged.

In preview mode, Firebase throws errors such as:

ReferenceError: window is not defined
or
FirebaseError: Firebase App named '[DEFAULT]' already exists

Environment:

Qwik: v2.0.0-beta.11

Firebase SDK: latest (v11.x)

Node: 20+

OS: macOS

Repro repo: https://github.com/wlans/qwik20bug

Notes:

Works perfectly on Qwik v1.

Possibly linked to where Firebase is initialized (e.g., in root vs route-level components).

Question:
Is anyone else experiencing Firebase auth issues with Qwik v2?
Could this be a known SSR or lifecycle regression between v1 and v2?

Reproduction

https://github.com/wlans/qwik20bug

Steps to reproduce

No response

System Info

System:
    OS: macOS 26.0.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 264.14 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.12.0 - /Users/wyattlansdale/.nvm/versions/node/v22.12.0/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.9.0 - /Users/wyattlansdale/.nvm/versions/node/v22.12.0/bin/npm
    pnpm: 9.10.0 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 142.0.7444.60
    Firefox: 143.0.3
    Safari: 26.0.1

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions