2

I know that if you are on a server environment, it probably makes more sense to use the firebase-admin SDK, that will grant you admin status on a trusted environment, like the one from a cloud function.

But these two packages have always gotten me confused: firebase JS SDK and firebase-admin.

See this excerpt from the firebase JS SDK

https://www.npmjs.com/package/firebase

This SDK is intended for end-user client access from environments such as the Web, mobile Web (e.g. React Native, Ionic), Node.js desktop (e.g. Electron), or IoT devices running Node.js. If you are instead interested in using a Node.js SDK which grants you admin access from a privileged environment (like a server), you should use the Firebase Admin Node.js SDK.

For a long time, I thought that the firebase JS SDK was completely incompatible with the Node.js environment of a cloud function, and that the mere presence or a simple import * as firebase from "firebase/app"; could break my function’s code. But I learned today that this is not the case. Is it?

In theory, could I use the firebase package to call firebase services from the Node.js environment of a cloud function?

Other than having admin privileges, if I’m only going to do a simple task like reading a firestore document, is there a reason why I should prefer using the firebase-admin instead of the firebase JS SDK package?