> Build error occurred
ReferenceError: navigator is not defined
at Object.areCookiesEnabled (/vercel/28f5c7d0/node_modules/@firebase/util/dist/index.node.cjs.js:650:5)
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
firebase.analytics();
}
// change to:
if (typeof window !== 'undefined' && !firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
firebase.analytics();
}
This happens when you try to initialize the firebase app server side, where the window object is not available.
In order to solve this, initialize the app inside useEffect hook (this way window object is available to firebase method):