Just starting out with Next.js development and currently following a Youtube tutorial on creating a Whatsapp clone using firebase8.9 as the database.
I am looking to implement a feature where the app checks if the user is logged in, if so redirect them to the home page, otherwise direct them to the login page.
import '../styles/globals.css'
import { useAuthState } from "react-firebase-hooks/auth"
import { auth, db } from "../firebase"
import Login from "./login"
function MyApp({ Component, pageProps }) {
const [user] = useAuthState(auth);
return <Component {...pageProps} />;
}
export default MyApp
This is how my firebase.js file looks:
import firebase from 'firebase';
const firebaseConfig = {
apiKey: "apikey",
authDomain: "authdomain",
projectId: "projectid",
storageBucket: "storagebucket",
messagingSenderId: "messagingsenderid",
appId: "appid"
};
const app = !firebase.apps.length ? firebase.initializeApp(firebaseConfig) : firebase.app();
const db = app.firestore();
const auth = app.auth();
const provider = new firebase.auth.GoogleAuthProvider();
export { db, auth, provider };
If anyone can assist me in resolving this issue, I would greatly appreciate it. Thank you in advance!