As we saw, Firebase admin SDK is only supported in Node.Js, so we'll create a new project with npm init and install the firebase admin from the npm package.
Run the following command to install firebase admin and save it in your package.json:
npm install firebase-admin --save
Copy the following snippet in your JS file and initialize the SDK; we have added the reference to the JSON file that we downloaded from the Firebase Admin Service account:
const admin = require('firebase-admin');
const serviceAccount = require('./firebase/serviceAccountKey.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://demoproject-7cc0d.firebaseio.com"
});
Now we'll just create Restful API to interact with client App to access Admin SDK features.
Run this command to start the node admin server:
node <fileName>
It will start the local server on a different port, such as http://localhost:3001.