http://localhost:3000
.http://localhost:3000
.http://localhost:3000
.loginWithRedirect()
method
to redirect users to the Auth0 Universal Login page where Auth0 can authenticate them. After a user successfully
authenticates, they will be redirected to the callback URL you set up earlier in this quickstart.Create a login button in your application that calls loginWithRedirect()
when selected.handleRedirectCallback()
function on the Auth0 client only when it detects a callback from Auth0. One
way to do this is to only call handleRedirectCallback()
when code
and state
query parameters are detected.If handling the callback was successful, the parameters should be removed from the URL so the callback handler
will not be triggered the next time the page loads.logout()
method that you can use
to log a user out of your app. When users log out, they will be redirected to your Auth0 logout endpoint,
which will then immediately redirect them to your application and the logout URL you set up earlier in this
quickstart.Create a logout button in your application that calls logout()
when selected.isAuthenticated()
function that allows you to check whether a user is
authenticated or not. You can render the login and logout buttons conditionally based on the value of
the isAuthenticated()
function. Alternatively, you can use a single button to combine both
login and logout buttons as well as their conditional rendering.getUser()
function exposed by the Auth0
client. The Auth0 client also exposes an isAuthenticated()
function that allows you to check whether
a user is authenticated or not, which you can use to determine whether to show or hide UI elements, for example.
Review the code in the interactive panel to see examples of how to use these functions.