Setup and Initialize Firebase Storage



Follow the steps to Setup and Initialize Firebase Storage for Web :

  1. Open your Firebase project console then go into Build > Storage and open it.
  2. Click on Get started and set security rules for cloud storage by selecting any option between 'Start in Production mode' or 'Start in Test mode'.
    [If you are new to firebase so go with the Test mode and letter set rules for firebase cloud storage.]


    Start in Production mode : You need to define security rules so third party can't use.

    Start in Test mode : Anyone can use it for 30 days using Firebase SDK after 30 days you have to set security rules. [you can also set before 30 days.]

     
    Firebase storage setup
  3. Select cloud storage location and hit Done
    Location selection in firebase storage
  4. Then wait till it create default bucket and setting up security rules for bucket after that you can storage dashboard
    Firebase Storage console
  5. Now setup firebase SDK and initialize storage
      So for that you need for storage location reference. You can find it to storage dashboard in Files tab then look in the header of the file viewer [You can see in above image] or you can get it from project settings.
  6. Open firebaseConfig object and add your storage URL in object. Its in this form '<PROJECT_ID>.appspot.com'.

Initialize Storage and simply export it so whenever you need Storage so just import it from firebaseConfig file.

firebaseConfig.js file :
import { initializeApp } from 'firebase/app';
import { getStorage } from 'firebase/storage';

const firebaseConfig = {
  // ...
  storageBucket: '<PROJECT_ID>.appspot.com',
  // ...
};

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

export const storage = getStorage(app); // Initialize Cloud Storage

Related Post
Upload File
How to Upload File to Firebase Storage ?
How to Upload File to Firebase Storage ?

1.Setup firebase SDK and initialize it 2.Upload file using 'uploadBytes((ref(storage, 'REFERENCE_PATH'), 'FILE'))' method

21 October 2024

Setup and Initialize
Setup and Initialize Firebase Storage
Setup and Initialize Firebase Storage

1.Open storage dashboard, 2.Click Get started, 3.Select Security rules and location, 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.