Steps to setup Firebase in Node JS Project
Create a Node Project
Initially set up a Nodejs Project using the following command.
npm init
OR
npm init -y
- The npm init command asks some setup questions that are important for the project
- npm init -y command is used to set all the answers to the setup questions as yes.
Firebase Installation
You can install the package with npm using the following command:
npm install firebase
or
npm i firebase
We can check the version of the firebase through the package.json file.
Create a Firebase Project
- Go to Firebase Console: Navigate to the Firebase Console.
- Add a New Project: Click on “Add project” enter your project name, configure Google Analytics (optional), and click “Create Project.”
Register Your Web App
- Add Firebase to Your Web App: In the Firebase console, click on the Web icon (</>) to register your web app.
- Enter a Name: Give your app a nickname and click “Register app.”
- Firebase SDK Setup: Firebase will provide a code snippet to add to your project. This snippet includes our project’s configuration.
import { initializeApp } from "firebase/app";
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_AUTH_DOMAIN",
projectId: "YOUR_PROJECT_ID",
storageBucket: "YOUR_STORAGE_BUCKET",
messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
appId: "YOUR_APP_ID"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
- Initially initializeApp function is imported from the firebase/app module which is used to initialize the app.
- firebaseConfig object contains different keys which are associated the with the services provided firebase like Cloud Firestore , Authentication , Cloud Messaging.
npm Firebase
Firebase is a product of Google that helps developers to build, manage, and grow their apps easily. It helps developers to build their apps faster and more securely. No programming is required on the Firebase side which makes it easy to use its features more efficiently. It provides services to Android, iOS, web, and Unity. It provides cloud storage. It uses NoSQL for the database to store data.
Contact Us