top of page

Introduction About Firebase | Firebase Project Help

Updated: Sep 22, 2020




What is Firebase?


The Firebase Command Line Interface (CLI) Tools can be used to test, manage, and deploy your Firebase project from the command line.

  • Deploy code and assets to your Firebase projects

  • Run a local web server for your Firebase Hosting site

  • Interact with data in your Firebase database

  • Import/Export users into/from Firebase Auth

To get started with the Firebase CLI, read the full list of commands below or check out the documentation.


Installation

Firebase installation is different as per different operating system:


Installation in windows

Firebase CLI is install in windows using two methods:

  • standalone binary

  • npm

standalone binary

To download and run the binary for the Firebase CLI, follow these steps:

  1. Access the binary to open a shell where you can run the firebase command.

This is recommended for new developers or who does not know nodes.


npm

Below dome steps which is used to install it using npm


step1: Install Node.js using nvm-windows (the Node Version Manager). Installing Node.js automatically installs the npm command tools.


step2: Install the Firebase CLI via npm by running the following command

npm install -g firebase-tools

step3: Continue to log in and test the CLI



Install In Mac OS or Linux

In this three options are used to install it in mac or Linux:

  • automatic install script

  • standalone binary

  • npm


automatic install script

  • Run the following cURL command:

curl -sL https://firebase.tools | bash


standalone binary

1. Download the Firebase CLI binary for your OS: macOS | Linux


2. (Optional) Set up the globally available firebase command.

  • Make the binary executable by running chmod +x ./firebase_tools.

  • Add the binary's path to your PATH


npm

  • Install Node.js using nvm (the Node Version Manager). Installing Node.js automatically installs the npm command tools.

  • Install the Firebase CLI via npm by running the following command:

npm install -g firebase-tools


Log in and test the Firebase CLI


1. Log into Firebase using your Google account by running the following command:


firebase login

This command connects your local machine to Firebase and grants you access to your Firebase projects.


2. Test that the CLI is properly installed and accessing your account by listing your Firebase projects. Run the following command:


firebase projects:list

Update to the latest CLI version


windows:

  • standalone binary: Download the new version, then replace it on your system

  • npm: Run npm install -g firebase-tools

mac:

  • automatic install script: Run curl -sL https://firebase.tools | bash

  • standalone binary: Download the new version, then replace it on your system

  • npm: Run npm install -g firebase-tools

Linux:

  • automatic install script: Run curl -sL https://firebase.tools | bash

  • standalone binary: Download the new version, then replace it on your system

  • npm: Run npm install -g firebase-tools


Initialize a Firebase project

You establish a project directory using the firebase init command.

firebase init

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.



Configuration Commands

Below the some commands which mostly use in Firebase:

firebase --help

This the Firebase help command

Command Description

login Authenticate to your Firebase account. Requires access to a web browser.

logout Sign out of the Firebase CLI.

login:ci Generate an authentication token for use in non- interactive environments.

use Set active Firebase project, manage project aliases.

open Quickly open a browser to relevant project resources.

init Setup a new Firebase project in the current directory. This command will create a firebase.json configuration file in your current directory.

help Display help information about the CLI or specific commands.


Project Management Commands


Command Description

apps:create Create a new Firebase app in a project.

apps:list List the registered apps of a Firebase project.

apps:sdkconfig Print the configuration of a Firebase app.

projects:addfirebase Add Firebase resources to a Google Cloud Platform project.

projects:create Create a new Firebase project.projects:listPrint a list of all of your Firebase projects.



Ref : link



Why our expert Use Firebase


  • Build better apps

  • Improve app quality

  • Grow your business


Build better apps:

It is used to create better apps using below features:

  • Cloud Firestore

  • Firebase ML

  • Cloud Functions

  • Authentication

  • Hosting

  • Cloud Stoarage

  • Realtime Databases

Improve app quality:

  • Crashlytics

  • Performance Monitoring

  • Test Lab

  • App Distribution


Grow your business

  • In-app messeging

  • Google Analytics

  • Predictions

  • A/B Testing

  • Cloud Messing

  • Remote config

  • Dynamic Links



Example:


Crud Api using firebase:


Setting up firebase:-

1. Created a new project in firebase

2. Copied the SDK snippet that would help us link the firebase to our respective

application.

3. Created a firebase.utils.js file inside of src folder

4. Pasted the SDK snippet to link the firebase


Firebase.js file:-

It consists of the basic setup that is required to link the application to the firebase.


Here, fireDb.database().ref() is passing a reference to the database. This reference is

being used to implement various CRUD operations upon the collection consisting of the

required documents of the respective employee.


AddorEdit function:-

This function is triggered whenever the handlesubmit function is executed on submitting

the form.


ADD FUNCTIONALITY:

It consists of firebaseDb.child("contacts").push(obj, (err) => {} api that helps

us to create the collection using .child and .push pushes data inside that collection. It only gets executed if currentId is empty(i.e no existing user is selected) .


EDIT FUNCTIONALITY:

It consists of firebaseDb.child(`contacts/${currentId}`).set(obj, (err) => {}

api that helps us to edit an existing data of the selected user using .set method. It only gets executed if currentId is not empty(i.e existing user is selected) .


OnDelete Function:-

This function gets triggered whenever the delete button is being clicked on a particular user.

The id of that particular user is being saved inside currentId and using that the respective data of that user is being deleted.


DELETE FUNCTIONALITY:

It consists of firebaseDb.child(`contacts/${key}`).remove((err) => {} api that

helps us to remove an document from inside of contacts collection using .remove.


Storing the snapshot of the collection:-

For displaying the entire list of the employee the data needs to be stored inside of a state that would change each time with the input of the new user.


Using the firebaseDb.child("contacts").on("value", (snapshot) => {} we are getting access to the contact collection and then using the snapshot we are pulling the documents of contacts collection and storing it inside of the contact variable by setting the setContact value to the value of the snapshot.


Displaying the documents:-

After storing the real-time data from the database inside of the contact variable we are simply mapping through the Object and displaying the required datas as per the keys of each object.



If you need help in project related to realtime firebase project then you can contact us using below contact id:

contact@codersarts.com

bottom of page