Firebase App named ‘[DEFAULT]’ already exists (app/duplicate-app)

Fredric Cliver
1 min readSep 17, 2020

There are two types of error cases when you dealing firebase initiation with separation with moduling

Firebase App named '[DEFAULT]' already exists (app/duplicate-app)

It means You tried to initiate firebase duplicated.

Error: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp()

It means You need to initiate firebase before using.

When you using firebase in several modules, and you’d tried to init firebase in each module. You would be faced with those errors.

So, you’d better make a file for the only purpose of initiating firebase like this.

// firebaseInit.tsimport firebase from "firebase/app"
import { firebaseConfig } from "./const"
export default !firebase.apps.length ? firebase.initializeApp(firebaseConfig) : firebase.app();

And import this file whereas you need to use firebase object.

--

--

Fredric Cliver

Majored in Physics, self-taught and worked in the IT industry as a Dev/Design/Planning for 11 years. And I had run my Startup for 3 years. I fancy a ☔️ 🇬🇧