import { initializeApp, getApps, getApp } from "@firebase/firestore";
import { getFirestore } from "@firebase/firestore";
const firebaseConfig = {
...config
};
export default function firebaseApp() {
if (!getApps().length) {
firebaseApp = initializeApp(firebaseConfig);
} else {
firebaseApp = getApp(firebaseConfig);
}
}
export const db = getFirestore(firebaseConfig)
Everything works fine until I try to export getFirestore as db. It works fine in CRA, but when I try to do it in Next.js I get the error "Cannot read property 'getProvider' of undefined".
I've tried everything I can think of: Used both yarn and npm, created multiple projects, imported getFirestore in another file. I am unsure what is causing this.