Skip to content

Instantly share code, notes, and snippets.

@ernestofreyreg
Created January 16, 2020 14:31
Show Gist options
  • Save ernestofreyreg/5a761860e164c83e56267d75a454cbde to your computer and use it in GitHub Desktop.
Save ernestofreyreg/5a761860e164c83e56267d75a454cbde to your computer and use it in GitHub Desktop.
import * as React from 'react'
import { NextPage } from 'next'
import { useAuth0 } from '../lib/auth0-spa'
interface Props {}
const Page: NextPage<Props> = () => {
const { isAuthenticated, loginWithRedirect, logout, user } = useAuth0()
return (
<div>
<h1>Initial Page</h1>
<div>
{!isAuthenticated && (
<button onClick={() => loginWithRedirect({})}>Log in</button>
)}
{isAuthenticated && (
<div>
<p>{user && user.nickname}</p>
<button onClick={() => logout()}>Log out</button>
</div>
)}
</div>
</div>
)
}
export default Page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment