Last active
December 28, 2021 15:45
-
-
Save skolhustick/d9cc49b0e98356d49429518c5cd6f928 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { signOut, useSession } from 'next-auth/react' | |
import Link from 'next/link' | |
import React from 'react' | |
const Homepage = () => { | |
const { data: session, status } = useSession() | |
if (status === 'loading') { | |
return <>Loading...</> | |
} | |
if (status === 'authenticated') { | |
return ( | |
<> | |
Signed in as {session.user.email} <br /> | |
<button onClick={() => signOut()}>Sign out</button> | |
</> | |
) | |
} | |
if (status === 'unauthenticated') { | |
return ( | |
<> | |
Not signed in <br /> | |
<Link href='/api/auth/signin'> | |
<a>Login</a> | |
</Link> | |
</> | |
) | |
} | |
} | |
export default Homepage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment