Back to photostream

Setting Up Firebase Locally

The Firebase CLI consists of an enumerator which emulates the following functions-

codeforstartups.com/lecture/setting-up-firebase-locally

 

HTTPS functions

 

Callable

 

Cloud Firestore Functions

 

You can easily test these functions locally before deploying to production.

 

Following are the steps to be followed to set up your Firebase locally

 

Step1: Install Firebase CLI

 

To use the cloud function emulator you need to Install Firebase CLI.

 

In order to use the local emulator, your Cloud Functions must depend on:

 

firebase-admin version 8.0.0 or higher.

 

firebase-functions version 3.0.0 or higher.

 

 

Step2: Set up admin credentials

 

If you want your function tests to interact with Google APIs via Firebase Admin SDKs, you will have to set up an admin credential for yourself.

 

To set up admin credentials for emulated functions:

 

Open the Service Accounts pane of the Google Cloud Console.

 

Make sure that App Engine default service account is selected, and use the options menu at right to select Create key.

 

When prompted, select JSON for the key type, and click Create.

 

Set your Google default credentials to point to the downloaded key

 

 

Step3: Set up Functions Configurations. (optional)

 

If you're using custom functions configuration variables, first run the command to get your custom config (run this within the functions directory) in your local environment.

 

Step4: Run the emulator suite

 

To run the Cloud Functions emulator, use the emulators:start command.

 

The emulators:start command will start emulators for Cloud Functions, Cloud Firestore, Realtime Database, and Firebase Hosting based on the products you have initialized in your local project using firebase init. If you want to start a particular emulator, use the --only flag

 

 

Interaction with other services;

The emulator suite includes multiple emulators, which enable testing of cross-product interactions. Following are the few platforms that you can use.

 

Cloud Firestore

 

Firebase Hosting

 

Logging

30 views
0 faves
0 comments
Uploaded on November 10, 2020