-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirebase.js
31 lines (28 loc) · 1.05 KB
/
firebase.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// import { initializeApp, getApps, getApp } from "firebase/app";
// import { getFirestore } from "firebase/firestore";
// import { getAuth, GoogleAuthProvider } from "firebase/auth";
import firebase from "firebase/compat/app";
import "firebase/compat/firestore";
import "firebase/compat/auth";
const firebaseConfig = {
apiKey:process.env.NEXT_PUBLIC_FIREBASE_APIKEY,
authDomain:process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
projectId:process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
storageBucket:process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
messagingSenderId:"946261875744",
appId:"1:946261875744:web:d410a9319fe1bf7703f045"
};
const app = !firebase.apps.length
? firebase.initializeApp(firebaseConfig)
: firebase.app();
const db = app.firestore();
const auth = app.auth();
const googleProvider = new firebase.auth.GoogleAuthProvider();
const signInWithGoogle = () => {
auth.signInWithPopup(googleProvider).then((res) => {
console.log(res.user)
}).catch((error) => {
console.log(error.message)
})
}
export { db, auth, signInWithGoogle };