‘Firebase Not Defined’ An Answer For Version 9 Of Firebase

Im trying to make a database call/post but im getting the error

functions.js:7 Uncaught ReferenceError: firebase is not defined

From my research it is my understanding that ‘firebase’ is defined in the firebase.js script file that is imported using the CDN code from the setting panel in Firebase.. But all the help pages i find are from 2014-2017 and version 9 of Firebase uses a completely different import language.. These pages are no help to me..

I am using the standard

import { initializeApp } from "https://www.gstatic.com/firebasejs/9.1.3/firebase-app.js";

Am I right in thinking that because this import is happening (and its seemingly is – firebase-app.js is showing up in the inspector) That firebase should be defined…

Or is firebase defined somewhere else and im missing something?? If this is the case where is firebase defined and how do i import it (with V9 Firebase)


Edit: Im doing this all through a tutorial I found on Youtube, its from 2019.. Is it possible that calling upon ‘firebase’ now is outmoded and that is what I am having these troubles? Or should i expect it to work and keep trying to find a solution?


In v8 and older versions of the Firebase Web SDK, now referred to as the “namespaced SDK”, the SDK would add methods and types to a global object called firebase. You will see a lot of existing tutorials with code that looks like firebase.initializeApp(), firebase.database() and firebase.firestore.FieldValue.increment(). All of these calls will not work in the newer versions of the Firebase Web SDK.

In v9 and later versions of the Firebase Web SDK, now referred to as the “modular SDK”, the SDK undertook a major architectural revamp and introduced lots of breaking changes. The primary change with the new version is that the firebase global object was completely removed and every method and type is now exported independently. When using this new SDK with a build tool like Webpack or Rollup, it can “shake the tree” to loosen and remove all of the bits of code that you don’t actually use in your code from the final build.

As an example, if you don’t use any of the FieldValue transforms in your code (like increment(), serverTimestamp() and arrayUnion()) they won’t be included in your final build saving you and your users resources and time.