Is it possible to reinitialize the default firebase app?

Viewed 428
//first call to initialize app
if (!firebase.apps.length) {
  firebase.initializeApp(config)
}

When the user logs out, I need them to disconnect to the realtime database.

firebase.app().delete().then( () => {
 if (!firebase.apps.length) 
 {
    firebase.initializeApp(config)
 }
 this.goToSignin();
})

However, when I try to sign in again I get an error saying the default app is already deleted

FirebaseError: Firebase: Firebase App named '[DEFAULT]' already deleted (app/app-deleted).
1 Answers

I don't think you're supposed to ever re-initialize an app of the same name, even if the previous one is deleted. But I'm not entirely sure, so it might be worth to reach out to Firebase support for personalized help in troubleshooting.

In the meantime, I'd recommend generating named app instances, so that you can control their name.

const app = firebase.initializeApp(config, "myname");

You can then pass app around and use that instead of firebase in most places.

Related