Implementing a login button requires that you know IF you should show the button as well as how to implement the button.
The okta-react
SDK provides you with:
Function-based components can use the useOktaAuth
React hook (opens new window) to access the authService
or the authState
objects.
Class-based components can use the withOktaAuth
higher-order component (opens new window) to receive the authService
and authState
objects as props.
You can use the authState.isAuthenticated
property to show or hide a button depending on whether the user is signed in.
The authService.login()
method lets you specify the path you'd like the user to be navigated to after authenticating.
Function-based component example:
Class-based component example: