Search code examples
javascriptreact-nativefirebase-storagefirebase-tools

initialize firebase emulator storage


is there a way already how to use firebase storage emulator for local development?

I found out it should be possible these days using the firebase-tools I guess but I cant figure out how to include it in my code.

this is my firebase config for localhost

import firebase from "firebase/app"
import "firebase/auth"
import "firebase/firestore"
import "firebase/functions"
import "firebase/storage"
import "firebase/database"

 firebase.initializeApp({
   apiKey: "-------------------",
   authDomain: "http://localhost:9099",
   databaseURL: "http://localhost:9000?ns=project-name",
   projectId: "project-name",
   storageBucket: "default-bucket",
   messagingSenderId: "--------------",
   appId: "----------------------",
   measurementId: "-----------------",
})

firebase.firestore().settings({ host: "localhost:8080", ssl: false })
firebase.auth().useEmulator("http://localhost:9099")
firebase.functions().useEmulator("http://localhost5001")
firebase.database().useEmulator("http://localhost:9090")

For now when I am trying to store something in the bucket this url is executed:

https://firebasestorage.googleapis.com/v0/b/default-bucket/o?name=test-file.csv

As I understand it properly, the app is not getting any local storage domain but only the firebase cloud storage domain


Solution

  • Just in case somebody will be struggling on the same case.

    I was using firebase 8.2.3 and based on SDK availability I was supposed to use firebase 8.4.0 or higher

    https://firebase.google.com/docs/emulator-suite/install_and_configure#client_sdk_availability