Skip to content
Advertisement

Firebase – Vue database integration not working

I am trying integrating Firebase with Vue 4 application is currently getting the following error.

Uncaught TypeError: db__WEBPACK_IMPORTED_MODULE_1_.default.database is not a function

I am using “firebase”: “^9.0.0” “vue”: “^3.0.0”

JavaScript

My function call is as below

JavaScript

I tried the following the following suggestion but it didn’t work.

Thank you!

Advertisement

Answer

The new modular SDK does not use namespaces anymore. So you cannot use app.database(). You can simply export a database instance from the file where you initialize Firebase as shown below:

JavaScript

Then import this wherever you need and use it:

JavaScript

You can learn more about the new syntax in the documentation


Uncaught TypeError: db._checkNotDeleted is not a function

This error arise due to the fact the you are importing ref from both firebase and vue. Please import Firebase’s ref as fireRef.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement