export async function getServerSideProps(context) {
const session = await getSession(context)
if (!session) {
return {
redirect: {
destination: '/',
permanent: false,
},
}
}
return {
props: { session }
}
}
useEffect(() => {
if (userData.email) {
router.push('/redirect') // redirects if there is no user
}
}, [userData])