change the following firebase v8 code into firebase v9: in javascript

Here is an example of how to migrate from Firebase v8 to v9 in JavaScript:

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

firebase.initializeApp(config);
const auth = firebase.auth();
const firestore = firebase.firestore();

// v9
import { initializeApp } from 'firebase/app';
import { getAuth } from 'firebase/auth';
import { getFirestore } from 'firebase/firestore';

const app = initializeApp(config);
const auth = getAuth(app);
const firestore = getFirestore(app);
444 chars
18 lines

In Firebase v9, the firebase namespace is no longer used. Instead, you need to import specific functions from Firebase modules. You can also use initializeApp to create a Firebase app instance. Then, you can use getAuth and getFirestore to retrieve Auth and Firestore instances using the app instance.

gistlibby LogSnag