Search code examples
firebasegoogle-cloud-firestoreraspberry-piraspberry-pi-zero

Should I be using firebase or firebase-admin on raspberry pi?


When writing Node.JS application for a Raspberry Pi communicating with Firebase, which npm module should be used?

What is the ideal way of doing things when on Raspberry Pi? Is it using firebase-admin or firebase package?


Solution

  • Both the regular Firebase client SDK, and the Firebase Admin SDK for servers can be used on a Raspberry Pi Node.js application. Which one to use depends on how you use the device and app.

    The firebase module accesses Firebase as a regular client application, similar to how any other web app, iOS app, or Android app would access it. So with this SDK you'll typically ask the user to sign in with Firebase Authentication, and then use those credentials to access their data in Cloud Firestore.

    The firebase-admin module however accesses Firebase as an administrative client. This means that it is authorized through pre-configured credentials, and can then access all data in Firestore and the rest of the Firebase project without any limitations. This SDK is used when you're creating an administrative application, that you then run on your Raspberry Pi.

    So: if you're building a regular application that requires no special permissions, use the firebase module. If you're building an admin-type application that requires elevated permissions, use the firebase-admin module.