-
I don't want the page to show up to ask the user. Just send them straight to the homepage. Is there a way to do this? |
Beta Was this translation helpful? Give feedback.
Answered by
jaaneh
Dec 29, 2020
Replies: 1 comment
-
If you're asking for e.g a "log out" button that instantly logs out, you can do something like this. <div onClick={() => signOut()}>
Sign out
</div> By calling and invoking the export const getServerSideProps = async ({ req }) => {
const session = await getSession({ req })
if (!session) {
return {
props: {},
redirect: {
destination: '/',
permanent: false
}
}
}
return {
props: {}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
balazsorban44
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you're asking for e.g a "log out" button that instantly logs out, you can do something like this.
By calling and invoking the
signOut
method, it will sign the user out on click. Paired with something like this (or your own redirect/auth check method) should work as expected.