Home > Net >  how to connect in latest firebse version?
how to connect in latest firebse version?

Time:03-17

this is my firebase config.js file. when i run the program it wont run with error msg "import firebase from "/node_modules/.vite/firebase_app.js?v=46ca94a2";

it only worked when replaced firebase with older version (8..) but i got several vulnerabilities in my log.can anyone point out the problem , i want to use latest version if possible? i checked the documentation but i found nothing is different from my code https://firebase.google.com/docs/auth/web/start

import firebase from "firebase/app";
import 'firebase/firestore'
import "firebase/auth";


const firebaseConfig = {
  ....
}

firebase.initializeApp(firebaseConfig);

const projectFirestore = firebase.firestore()
const timestamp = firebase.firestore.FieldValue.serverTimestamp
const projectAuth = firebase.auth()

export {projectFirestore,timestamp,projectAuth}

CodePudding user response:

There are several things that changed with Firebase 9, a reference guide is available here: https://firebase.google.com/docs/web/modular-upgrade

I cannot list all the changes here because there is quite a few and it depends on what/how you're already using it right now and which one you want to use later on (compat or modular).

But mainly, you will need to write the imports like this now

import { initializeApp } from "firebase/app"

The whole changelogs are available here.

  • Related