We're using firebase as part of our backend to accelerate the process of making prototype of our app (serverless):
-
User authentification managed by Firebae auth.
-
Data stored in database is managed by Firestore.
-
Photos uploaded in our app is managed by Firebase storage.
-
Scheldued tasks are managed by Firebase cloud functions.
To use Firebase in your proect your need to create a Firebase project using Firebase console. and install Firebase tools (CLI)
A minimium of knowledge is required of the following frameworks and technologies:
-
Node.js
-
Firebase SDK
-
Firestore
-
Firebase Storage
-
Firebase Cloud Functions
First you need to install Firebase tools using a method that matches your operating system by following Firebase CLI documentation.
I'm using Ubuntu 20.04 for developement, so I'm running this command:
curl -sL firebase.tools | upgrade=true bash
After installing the CLI, you must authenticate.
- Log into Firebase using you Google account:
firebase login
- Link your Firebase project and initialize it inside backend folder:
firebase init
The firebase init
command steps you through setting up your project directory and some Firebase products.
At the end of initialization, Firebase automatically creates the following two files at the root of your local app directory:
-
A firebase.json configuration file that lists your project configuration.
-
A .firebaserc file that stores your project aliases.
For your developement & test, It would be better to run it locally rather using production envirement to test your work.
Firebase provide a local emulator for almost all their services to test aigaint them locally: Firebase Local Emulator Suite
Emulator suite is part Firebase CLI, so all you need now is to run this command:
firebase init emulators
For more information about ho to install and configure emulators, check "Install, configure and integrate"
After setting up the emulators, run this command to start them:
firebase emulators:start
The Firebase CLI manages deployment of code and assets to your Firebase project, including:
Command list we need for our project are the following:
- Cloud Storage for Firebase rules
firebase deploy --only storage
- Cloud Firestore rules and indexes
firebase deploy --only firestore
- Cloud Firestore rules
firebase deploy --only firestore:rules
- Cloud Firestore indexes
firebase deploy --only firestore:indexes
- Cloud Functions for Firebase
firebase deploy --only functions
You may combine all these commands into one command:
firebase deploy --only functions,firestore,storage