question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compatibility with Firebase Modular JS SDK (v9)

See original GitHub issue

What problem is this solving

Firebase recently introduced the modular web SDK, currently in beta. One of its goals is to reduce the footprint of the lib allowing tree shaking. Therefore, a lot of users might want to benefit from using it.

Using vuexfire does currently not seem to be working with the new Firebase modular SDK because of the changed API:

TypeError: document.onSnapshot is not a function
    at bindDocument (webpack-internal:///./node_modules/vuexfire/dist/vuexfire.esm.js:456)
    at eval (webpack-internal:///./node_modules/vuexfire/dist/vuexfire.esm.js:614)
    at new Promise (<anonymous>)
    at bind$1 (webpack-internal:///./node_modules/vuexfire/dist/vuexfire.esm.js:603)
    at bindFirestoreRef (webpack-internal:///./node_modules/vuexfire/dist/vuexfire.esm.js:655)

See here for the new way the API works. What used to be something like this:

db.collection("cities").doc("SF")
    .onSnapshot((doc) => {
        console.log("Current data: ", doc.data());
    });

…is now something like this:

import { doc, onSnapshot } from "firebase/firestore";

const unsub = onSnapshot(doc(db, "cities", "SF"), (doc) => {
    console.log("Current data: ", doc.data());
});

That’s why I think the bindFirestoreRef(...) now needs to be adjusted to adjust to the new API.

Proposed solution

As version 9 of the Firebase JS SDK will be the modular one, adjust to the new API so that vuefire/vuexfire works with the Firebase 9 JS SDK.

Describe alternatives you’ve considered

Stick with Version 8 of the Firebase JS SDK for now.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:33 (8 by maintainers)

github_iconTop GitHub Comments

33reactions
bangdragoncommented, Aug 30, 2021

Firebase v9 has been released, hope you guys release vuexfire soon. Thanks

20reactions
gabrielnviancommented, Oct 16, 2021

What’s the progress on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrade from version 8 to the modular Web SDK - Firebase
Compat - a familiar API surface which is fully compatible with the version 8 SDK, allowing you to upgrade to version 9 without...
Read more >
Why the New Firebase Web v9 Modular ... - DEV Community ‍ ‍
Compatibility. The new Firebase Web v9 SDK makes it easy to progressively upgrade from the v8 SDK. The firebase package provides a compat ......
Read more >
Firebase: Upgrade from version 8 to modular web SDK (v9)
A new API surface designed to removal of unused code to make your web app as small and fast as possible. As we...
Read more >
Working with Firebase Version 9 Modular SDK and React ...
​​Firebase Modular SDK (Version 9) ... ​​There was a recent release by Firebase; this current version came with some syntactic changes compared to ......
Read more >
Refactor a React app with the new Firebase v9.x Web SDK
The new web SDK moves away from the namespace approach that was used in version 8. Instead, it adopts a modular format optimized...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found