I'm currently working with Firestore database in my Node.js application, but I get confused with the different options to get the firestore client. In the past, I was using firebase-admin to connect to my firestore database and get the client, but then I found out I can also use the @google-cloud/firestore npm package to do the same thing.
In their @firebase/firestore package, they suggest you to use @google-cloud/firestore package:
This is the Cloud Firestore component of the Firebase JS SDK.
This package is not intended for direct usage, and should only be used via the officially supported firebase package.
If you are developing a Node.js application that requires administrative access to Cloud Firestore, use the @google-cloud/firestore Server SDK with your developer credentials.
But in their official docs they suggest to use firebase-admin:
Set up your development environment Add the required dependencies and client libraries to your app.
Add the Firebase Admin SDK to your app:
npm install firebase-admin --save
firebase-admin is just a thin wrapper around @google-cloud/firestore (among other products, under one umbrella). They have the exact same API once you get a hold of a Firestore object. Use either one you want - there is no "correct" solution.
firebase-admin is intended to be easier to use for people already using other Firebase products on their backend. But you can decide what is easiest for you.
@firebase/firestore is meant for use in web applications and is not meant for use in nodejs apps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With