Skip to content

Replace reactfire with custom hooks and upgrade firebase SDK 9 -> 12 #191

Open

Description

@epodol

Problem

reactfire 4.2.x is dead (last publish Aug 2023) and pins firebase to ^9 — it is the blocker for upgrading the client Firebase SDK (currently 9.23) to 12.x. Both changes touch every data callsite, so they should land together.

There is also a React correctness bug in src/pages/MindMap/index.tsx to fix in the same pass: useState(rootNode) is called after two conditional throw statements (rules-of-hooks violation), and mindmap.nodes is dereferenced before the if (!mindmap) throw guard, so a missing/denied doc dies with a raw TypeError instead of the intended error message.

Proposed approach

  • Replace reactfire with 3–4 small custom hooks over the modular SDK (onSnapshot, onAuthStateChanged). Do not swap for react-firebase-hooks (even less maintained).
  • Bump firebase 9 -> 12 in the same PR, since the callsites are already being rewritten.
  • Fix the hooks-order bug and the pre-guard dereference in src/pages/MindMap/index.tsx while touching the file.
  • While in App.tsx, delete the unused Storage init (no emulator/rules/usage) and the unused Remote Config init (remoteconfig.template.json is {}).
  • Verify auth flows (Google, password, anonymous) and Firestore sync against emulators.

Acceptance criteria

  • reactfire removed from package.json; firebase at 12.x
  • Auth + Firestore live sync work against emulators and prod config
  • No rules-of-hooks lint errors in src/pages/MindMap/index.tsx; missing/denied doc shows the intended error
  • Unused Storage and Remote Config init removed

References

ROADMAP.md sections 3 (dependency table: reactfire, firebase rows; App.tsx dead weight) and 8 (hooks bug).

Activity

  1. epodol commented on Jul 7, 2026

    @epodol
    CollaboratorAuthor

    Landed on the revival branch (PR #199), commit d0597dd.

    reactfire is gone, replaced by src/firebase/index.tsx: module-level singleton SDK init (app → App Check → auth/firestore/functions, emulator wiring) plus the hooks the app actually uses — useAuth/useFirestore/useFunctions, useUser/useSigninCheck (one app-wide onIdTokenChanged subscription behind FirebaseUserProvider), and useFirestoreDocData/useFirestoreCollection/useFirestoreCollectionData (onSnapshot, { status, data } shape, queryEqual-stable resubscription).

    Also in this pass, per the issue scope: firebase 9 → 12, @firebase/rules-unit-testing 2 → 5, the unused Storage/Remote Config inits deleted (plus remoteconfig.template.json), and the MindMap rules-of-hooks bug fixed by splitting the component into loader + LoadedMindMap — missing/denied docs now surface the friendly error instead of a raw TypeError.

    All 41 emulator tests, tsc, eslint, and the prod build are green. Closing when PR #199 merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions