Setup and Initialize Realtime Database



Follow the steps to Setup and Initialize Firebase Realtime Database for Web :

  1. Open your Firebase project console then open Build > Realtime Database
  2. Click on Create Database and select location for database.
    Setup Database
  3. If you use this as production purpose then go with "locked mode" otherwise use "test mode".
    Security Rules
    1. 1. "locked mode" : You need to defined Security Rules for database to third party can't use.
      2. "test mode" : Anyone can read or write using Firebase SDK.
  4. Click on Enable and hear you go.
    Realtime Database Screen
  5. Now setup firebase SDK and Initialize firebase Realtime Database.

firebaseConfig.js :
import { initializeApp } from 'firebase/app';
import { getDatabase } from 'firebase/database';

const firebaseConfig = {
  // ...
  databaseURL: '<DATABASE_URL>',
  // ...
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);

// Initialize Realtime Database
export const database = getDatabase(app);

Now just import 'database' from 'firebaseCofig' file and use realtime database functions in your app.
Related Post
Write data
How to Save Data to Realtime Database ?
How to Save Data to Realtime Database ?

1. Setup Firebase SDK and Initialize it 2. Save data : use "set (ref(database, 'PATH_TO_SAVE'), 'DATA')" method

21 October 2024

Update and Delete data
How to Update and Delete data to Realtime Database ?
How to Update and Delete data to Realtime Database ?

1. Setup Firebase SDK and Initialize it, 2.Update data using 'update()' method 3.Delete data using 'remove()'method

21 October 2024

Read data
How to Read Data from Realtime Database ?
How to Read Data from Realtime Database ?

1.Setup and Initialize it, 2.You can read data using 'get()' and 'onValue()' method

21 October 2024

Setup and Initialize
Setup and Initialize Realtime Database
Setup and Initialize Realtime Database

1.Open realtime database dashboard, 2.Click Create Database, 3.Select location and Security rules, 4.Setup Firebase SDK and Initialize it

21 October 2024

Company
Explore

Copyright © 2024, All rights reserved by Firebase Master

We value your privacy

We use cookies to enhance your browsing experience, serve personalized ads or content, and analyze our traffic. By clicking "Allow", you consent to our use of cookies. Here is our Privacy Policy.