React Getting Started
This integration guide will walk you through setting up and managing authentication and authorization in your React apps using Auth0.
Get Your Application Keys
When you signed up for Auth0, you were invited to create a new client.
There are some details about this client that your application needs to know about to properly communicate with Auth0, including your Client ID and Domain. You can retrieve these values from the settings area for your client in the Auth0 dashboard.
Please note that if you download the samples available for this tutorial, these keys will be pre-populated for you. If you have created more than one client in your account, the sample will come with the values for your Default App.
Configure Callback URLs
A callback URL is a URL in your application where Auth0 redirects to after the user has authenticated. You need to whitelist a callback URL for your app in the Callback URLs field in your Client Settings. If no callback URLs are set, a mismatch error will be displayed when a user logs in.
Integrating Auth0 in your application requires the auth0.js library. Install it using npm or yarn.
# installation with npm npm install --save auth0-js # installation with yarn yarn add auth0-js
Once auth0.js is installed, add it to your build system or bring it in to your project with a script tag.
If you don't want to use a package manager, auth0.js can also be retrieved from Auth0's CDN.
About the Sample Applications
Each section of this guide has a unique downloadable sample. Within each of these samples you will find a very simple React application which utilizes a few components. The samples are built with create-react-app and use react-router v4 (with
It should be noted that the sample applications are intentionally simplistic. The focus of this guide is on how to use Auth0 in a React application in general rather than on how to approach various architectural scenarios. However, Auth0 works well in any React setup and can be integrated with Flux, Redux, and other flavors that you may be interested in.