Skip to content

Instantly share code, notes, and snippets.

@mbrown3321
Created October 9, 2020 00:33
Show Gist options
  • Save mbrown3321/997199ddf779b520097ebccf2c51a2f7 to your computer and use it in GitHub Desktop.
Save mbrown3321/997199ddf779b520097ebccf2c51a2f7 to your computer and use it in GitHub Desktop.
App.js - with logout
import React from 'react';
import { Navbar, Nav, Button } from "react-bootstrap"
import { useAuth0 } from "@auth0/auth0-react";
import 'bootstrap/dist/css/bootstrap.min.css';
const App = () => {
const { loginWithRedirect, isAuthenticated, logout } = useAuth0();
return (
<div>
<Navbar bg="dark" variant="dark">
<Navbar.Brand href="#home">Auth0</Navbar.Brand>
<Nav className="ml-auto">
{
isAuthenticated
? (
<Button onClick={() => logout()}>Logout</Button>
) : (
<Button onClick={() => loginWithRedirect()}>Login</Button>
)
}
</Nav>
</Navbar>
</div>
);
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment