QwikDev / QwikDev/qwik

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

Open
#8,108 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

missing info V2
Dominant language
TypeScript
Stars
22.1k
Forks
1.4k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction repository at https://github.com/wlans/qwik20bug and run the reported npm run dev and npm run preview flows using Qwik v2.0.0-beta.11 and Firebase SDK 11.x. Compare route behavior and preview errors with Qwik v1; done means onAuthStateChanged fires consistently across routes and preview no longer reports window or duplicate Firebase app errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
firebase, typescript
Domain
authentication, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.