Skip to content

Send and receive SMS messages using your Android phone programmatically via a simple HTTP API

fix(web): await compat SDK initialization to prevent race condition

Acho Arnold6d98ef212c7e
diff --git a/web/app/plugins/firebase.client.ts b/web/app/plugins/firebase.client.ts
index aabdfe0f..86b4e827 100644
--- a/web/app/plugins/firebase.client.ts
+++ b/web/app/plugins/firebase.client.ts
@@ -3,7 +3,7 @@ import type { FirebaseApp } from "firebase/app";
import { getAuth, onAuthStateChanged } from "firebase/auth";
import { useAuthStore } from "../stores/auth";
-export default defineNuxtPlugin(() => {
+export default defineNuxtPlugin(async () => {
const config = useRuntimeConfig();
const publicConfig = config.public as Record<string, string>;
@@ -32,18 +32,15 @@ export default defineNuxtPlugin(() => {
// Also initialize the compat SDK for FirebaseUI
if (import.meta.client) {
- import("firebase/compat/app").then(
- (firebase: {
- default: {
- apps: unknown[];
- initializeApp: (config: typeof firebaseConfig) => void;
- };
- }) => {
- if (!firebase.default.apps.length) {
- firebase.default.initializeApp(firebaseConfig);
- }
- },
- );
+ const firebase = (await import("firebase/compat/app")) as {
+ default: {
+ apps: unknown[];
+ initializeApp: (config: typeof firebaseConfig) => void;
+ };
+ };
+ if (!firebase.default.apps.length) {
+ firebase.default.initializeApp(firebaseConfig);
+ }
}
// Listen for auth state changes and update the auth store