Setup Firebase in angular application

First, we need to create an account of firebase for angular application. You need to go to the URL and creating an account. After creating an account there is an option for creating a project. Click on the add project after adding the project it will display like below screen.

Click on the web icon then you can get the firebase configfile.

<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src=""></script>

<!-- TODO: Add SDKs for Firebase products that you want to use -->

  // Your web app's Firebase configuration
  var firebaseConfig = {
    apiKey: "API KEY",
    authDomain: "domain",
    databaseURL: "url",
    projectId: "project",
    storageBucket: "storage",
    messagingSenderId: "Sender ID",
    appId: "aPP id"
  // Initialize Firebase

Now you can copy these firebase config in our angular project. Add these config in “src/environments/environment.ts”

export const environment = {
  firebase: {
    apiKey: "YOUR_API_KEY",
    authDomain: "YOUR_AUTH_DOMAIN",
    databaseURL: "YOUR_DATABASE_URL",
    projectId: "YOUR_PROJECT_ID",
    storageBucket: "YOUR_STORAGE_BUCKET",
    messagingSenderId: "YOUR_SENDER_ID"

You need to install module for firebase in our angular application.

npm install @angular/fire firebase --save

Need to import firebase library “app.module.ts”

import { AngularFireModule } from '@angular/fire';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { environment } from '../environments/environment';
imports: [
  AngularFireAuthModule, // 

Using Firebase we can now use social logins like (facebook,twitter,linkedin, etc..).
Below is the example for the Facebook login using firebase. We need to create service.

import { AngularFireAuth } from 'angular/fire/auth';
import * as firebase from 'firebase/app';

constructor(public fbAuth: AngularFireAuth){


   return new Promise((resolve, reject) => {
     let provider = new firebase.auth.FacebookAuthProvider();
     .then(res => {
     }, err => {