Firebase storage is an object storage service provided by Google and is mainly used for user-generated data like audio, images, and videos.

It provides a simple way of uploading and downloading files securely with just a few lines of code. Here, we'll discuss all the basics you need to know.

How Firebase Storage Works

Firebase Cloud Storage stores files in a Google storage bucket provided by Google Cloud. You don't need a credit card when you're first starting out since Google's Firebase uses the default storage bucket.

As a result, you can get your application up and running fast. You can also use the Google Cloud Storage APIs to manage the uploaded content and control user access.

Key Benefits of Firebase Storage

Now that you know how Cloud Storage for Firebase works, we have listed some benefits of using Firebase storage below:

1. Reliable

When using a poor network, Firebase storage marks your progress and resumes when the network quality is stronger.

2. Secure

You can integrate Firebase authentication to control access to your application based on the file details such as name, size, and type.

3. Highly Scalable

Firebase storage can easily scale to meet your application's needs. This means you don't have to worry when your users increase exponentially.

Set Up Default Cloud Storage Bucket

The first step to implementing Firebase storage is to set up a default cloud storage bucket.

  1. On the Firebase console page, select add project and follow the instructions to create a new project.
  2. From the left navigation bar, select Storage, and then click on Get Started.
  3. For a quick setup, select Start in test mode.
  4. Click Next, and choose the cloud storage location.
  5. Click on Done.

Integrate Cloud Storage With Your App

You need to add the storage bucket URL to your app in order to use it.

To get the URL, go to the storage dashboard of your app. On the file tab, copy the URL in the header. You will use it in the Firebase config object when connecting your app to Firebase.

The following is an example of the config object.

        import { initializeApp } from "firebase/app";
import { getStorage } from "firebase/storage";
const firebaseConfig = {
 apiKey: '<your-api-key>',
 authDomain: '<your-auth-domain>',
 databaseURL: '<your-database-url>',
 storageBucket: '<your-storage-bucket-url>'
};
const firebaseApp = initializeApp(firebaseConfig);

You can then create a storage reference and start using the storage bucket you created

        const storage = getStorage(firebaseApp);
    

When to Use Firebase Storage

Firebase storage is a great choice when you want to create an application that utilizes user-generated data without too much coding. As we mentioned earlier, besides being secure and reliable, it's also highly scalable.