By Steve Hobbs
This tutorial demonstrates how to add user login to a React Native application using Auth0.We recommend that you log in to follow this quickstart with examples configured for your account. This Quickstart is for the React Native framework. To integrate Auth0 into your Expo application, please refer to the Expo QuickstartNew to Auth? Learn How Auth0 works, how it integrates with Native Applications and which protocol it uses.
Configure Auth0
Get Your Application Keys
When you signed up for Auth0, a new application was created for you, or you could have created a new one. You will need some details about that application to communicate with Auth0. You can get these details from the Application Settings section in the Auth0 dashboard.
When using the Default App with a Native or Single Page Application, ensure to update the Token Endpoint Authentication Method to
None and set the Application Type to either SPA or Native.- Domain
- Client ID
If you download the sample from the top of this page, these details are filled out for you.
Install Dependencies
In this section, you will install the React Native Auth0 module.Please refer to the official documentation for additional details on React Native.
Yarn
For further reference on yarn, check their official documentation.
npm
Additional iOS step: install the module Pod
Our SDK requires a minimum iOS deployment target of 13.0. In your project’s `ios/Podfile“, ensure your platform target is set to 13.0.ios folder and run pod install.

Integrate Auth0 in Your Application
Configure Android
Open your app’sbuild.gradle file (typically at android/app/build.gradle) and add the following manifest placeholders. The value for auth0Domain should contain your Auth0 application settings as configured above.
At runtime, the
applicationId value will automatically update with your application’s package name or ID (e.g. com.example.app). You can change this value from the build.gradle file. You can also check it at the top of your AndroidManifest.xml file.Configure iOS
AppDelegate Setup (Choose Based on Architecture)
If you’re using (Swift -ios/<YOUR PROJECT>/AppDelegat.swift) add the following in AppDelegate class:
ios/<YOUR PROJECT>/AppDelegate.mm) add the following:
This file will be
ios/<YOUR PROJECT>/AppDelegate.m on applications using the old architecture.ios folder, open the Info.plist and locate the value for CFBundleIdentifier
CFBundleIdentifier as the value for the CFBundleURLSchemes.
If your application was generated using the React Native CLI, the default value of
$(PRODUCT_BUNDLE_IDENTIFIER) dynamically matches org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier). For the sample app, this value matches com.auth0samples.- Open the
ios/<YOUR PROJECT>.xcodeprojfile or runxed ioson a Terminal from the app root. - Open your project’s or desired target’s Build Settings tab and find the section that contains “Bundle Identifier”.
- Replace the “Bundle Identifier” value with your desired application’s bundle identifier name.
Configure Callback and Logout URLs
The callback and logout URLs are the URLs that Auth0 invokes to redirect back to your application. Auth0 invokes the callback URL after authenticating the user, and the logout URL after removing the session cookie. If the callback and logout URLs are not set, users will be unable to log in and out of the application and will get an error. Go to the settings page of your Auth0 application and add the corresponding URL to Allowed Callback URLs and Allowed Logout URLs, according to the platform of your application. If you are using a custom domain, use the value of your custom domain instead of the Auth0 domain from the settings page.iOS
Android
If you are following along with our sample project, set this
- for iOS -
com.auth0samples.auth0://{yourDomain}/ios/com.auth0samples/callback - for Android -
com.auth0samples.auth0://{yourDomain}/android/com.auth0samples/callback
Add login to your app
Import theuseAuth0 hook and the Auth0Provider component from the react-native-auth0 package.
Auth0Provider component, providing your Auth0 domain and Client ID values:
Finally, present the hosted login screen using the authorize method from the useAuth0 hook. See this usage example showing logging in on a button click:
Checkpoint
Add a button component that callsauthorize when clicked. Verify that you are redirected to the login page and then back to your application.Add logout to your app
To log the user out, redirect them to the Auth0 log out endpoint by importing and calling theclearSession method from the useAuth0 hook. This method removes their session from the authorization server.
See this usage example of a button that logs the user out of the app when clicked:
Checkpoint
Add a button that callsclearSession when clicked. Verify that you are logged out of the application when clicked.Show user profile information
TheuseAuth0 hook exposes a user object that contains information about the authenticated user. You can use this to access decoded user profile information about the authenticated user from the ID token.
If a user has not been authenticated, this property will be null.