Download the sample React application To view a simple example of a React app, clone the Auth JS repository and follow the setup procedure:
Clone the Auth JS repository Clone the Auth JS repository and navigate to the top-level folder.
Install the dependencies Install the dependencies in the okta-auth-js
folder:
Add a configuration file Create and add a configuration file (testenv
) to the okta-auth-js
root folder. The testenv
file contains the configuration values for your app integration. See Create an Okta app integration for details on these values.
Run the sample application Navigate to the project folder and run the sample application. Click Login and sign in with a user from your Okta org. After a successful authentication, the user's access token appears on the page.
Create a React app (optional) If you don't have an existing React app, you can quickly create an app by using Create React App (opens new window) :
Go into your root app directory to view the created files:
Install dependencies Add the following dependencies to your React app:
And install the dependencies using a package manager in your root app directory:
Note: The sample code in this use case requires react-router-dom
version 5.x. Certain objects used in the sample code don't exist in reactor-router-dom
version 6.x.