diff --git a/web/pages/index.tsx b/web/pages/index.tsx index 473189aa..c1892939 100644 --- a/web/pages/index.tsx +++ b/web/pages/index.tsx @@ -6,6 +6,9 @@ import { ManifoldLogo } from 'web/components/nav/manifold-logo' import { redirectIfLoggedIn } from 'web/lib/firebase/server-auth' import { useSaveReferral } from 'web/hooks/use-save-referral' import { SEO } from 'web/components/SEO' +import { useUser } from 'web/hooks/use-user' +import { useEffect } from 'react' +import { useRouter } from 'next/router' export const getServerSideProps = redirectIfLoggedIn('/home', async (_) => { // These hardcoded markets will be shown in the frontpage for signed-out users: @@ -29,6 +32,15 @@ export default function Home(props: { hotContracts: Contract[] }) { useSaveReferral() + const user = useUser() + const router = useRouter() + useEffect(() => { + if (user) { + // Redirect to the /home page if the user is logged in. + router.push('/home') + } + }, [user, router]) + return (