I'm struggling to understand why the call to auth.currentUser
in the code snippet below always returns null. Interestingly, I have another component that can detect when a user is logged in correctly.
import { auth } from "../lib/firebase";
type Props = {
message: string;
};
const Page = ({ message }: Props) => {
useEffect(() => {
if (auth.currentUser) { // The condition never evaluates to true
const router = useRouter();
router.push("/home");
}
}, []);
return <div>{message}</div>
}
export default Page;
export const getStaticProps = async () => {
const message = await fetchMessage();
return {
props: { message },
};
};