Skip to content

Instantly share code, notes, and snippets.

@rahulmore01
Created July 11, 2024 09:19
Show Gist options
  • Save rahulmore01/e4b666b92b4cf0623fd0940584ccfef2 to your computer and use it in GitHub Desktop.
Save rahulmore01/e4b666b92b4cf0623fd0940584ccfef2 to your computer and use it in GitHub Desktop.
navbar with next auth
import { useSession, signIn, signOut } from "next-auth/react"
export default function Navbar() {
const { data: session } = useSession()
if (session) {
return (
<>
Signed in as {session.user.email} <br />
<button onClick={() => signOut()}>Sign out</button>
</>
)
}
return (
<>
Not signed in <br />
<button onClick={() => signIn()}>Sign in</button>
</>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment