The isAuthenticated
value represents the authentication state of your users it's tracked by the Auth0 React SDK. This value returns true
when the user has been authenticated and false
they're when not. Use isAuthenticated
to render UI elements conditionally depending on the authentication state of your users.
import { useAuth0 } from "@auth0/auth0-react";
import React from "react";
import { LoginButton } from "../../buttons/login-button";
import { LogoutButton } from "../../buttons/logout-button";
import { SignupButton } from "../../buttons/signup-button";
export const NavBarButtons = () => {
const { isAuthenticated } = useAuth0();
return (
<div className="nav-bar__buttons">
{!isAuthenticated && (
<>
<SignupButton />
<LoginButton />
</>
)}
{isAuthenticated && (
<>
<LogoutButton />
</>
)}
</div>
);
};
Authentication process doesn’t happen in your React application when using Auth0. Your React application will redirect your users to the Auth0 Universal Login page. Auth0 asks for credentials and redirects the user back to your application with the result of the authentication.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!