Skip to content

Commit

Permalink
refactor: prevent multi initialize app
Browse files Browse the repository at this point in the history
  • Loading branch information
FazioNico committed Jun 7, 2024
1 parent 733d6ef commit ac99fad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions firebase.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getApp, getApps, initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";
import { getDatabase } from "firebase/database";
// TODO: Add SDKs for Firebase products that you want to use
Expand All @@ -17,7 +17,7 @@ const firebaseConfig = {
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);
const app = !getApps().length ? initializeApp(firebaseConfig) : getApp();

// Initialize Realtime Database and get a reference to the service
const database = getDatabase(app);
Expand Down

0 comments on commit ac99fad

Please sign in to comment.