Get Started
1
Create a new Expo project
Create a new Expo project for this quickstart.In your terminal:
2
Install the Auth0 SDK
Add the Auth0 React Native SDK to your project.
3
Configure the Expo Plugin
Configure the Auth0 plugin to handle native iOS and Android configuration automatically.Update your Replace
app.json to include the Auth0 plugin:app.json
{yourDomain} with your Auth0 domain (you’ll get this in the next step).The
customScheme must be lowercase with no special characters. This value is used to construct callback URLs and must be passed to authorize() and clearSession() methods.4
Configure your Auth0 Application
Create and configure an Auth0 application to work with your Expo app.Allowed Logout URLs:Replace
- Head to the Auth0 Dashboard
- Click on Applications > Applications > Create Application
- In the popup, enter a name for your app (e.g.,
Auth0 Expo Sample), selectNativeas the app type and click Create - Switch to the Settings tab on the Application Details page
- Note your Domain and Client ID values
- Update the
domainvalue in yourapp.jsonplugin configuration with your Auth0 domain
{yourDomain} with your actual Auth0 domain (e.g., dev-abc123.us.auth0.com).Allowed Callback URLs are a critical security measure to ensure users are safely returned to your application after authentication. Without a matching URL, the login process will fail, and users will be blocked by an Auth0 error page instead of accessing your app.Allowed Logout URLs are essential for providing a seamless user experience upon signing out. Without a matching URL, users will not be redirected back to your application after logout and will instead be left on a generic Auth0 page.The
customScheme must match exactly with the value in your app.json plugin configuration.5
Setup App Component
Setup your main app component based on your chosen implementation approach.
- Hooks-based (with Provider)
- Class-based (without Provider)
Replace the contents of Replace
App.js and wrap your application with the Auth0Provider component:App.js
{yourDomain} with your Auth0 domain and {yourClientId} with your Client ID from the Auth0 Dashboard.The
authorize() method opens Auth0’s Universal Login in a secure browser (ASWebAuthenticationSession on iOS, Chrome Custom Tabs on Android). The clearSession() method logs the user out and clears both the browser session and stored credentials. The customScheme parameter must match the value in your app.json plugin configuration.6
Run your app
Build and run your Expo application on a device or emulator.First, generate the native iOS and Android projects:Then run on your target platform:For iOS:For Android:Expected flow:
- App launches showing “Log In” button
- Tap Log In → Browser opens with Auth0 Universal Login
- Complete login (sign up or sign in)
- Browser closes → Returns to app automatically
- User profile displays with name, email, and avatar
CheckpointYou should now have a fully functional Auth0 login experience running on your device or emulator. The app uses secure browser authentication and automatically manages credentials in the device’s secure storage.
Troubleshooting & Advanced
Common Issues & Solutions
Common Issues & Solutions
”Invariant Violation: Native module cannot be null”
This error occurs when attempting to use the SDK with Expo Go.Solution:The Auth0 SDK requires custom native code that isn’t available in Expo Go. Use a development build instead:Callback URL mismatch error
Solution:Verify all three of these match exactly:customSchemeinapp.jsonplugin configurationcustomSchemeparameter passed toauthorize()andclearSession()- Callback URLs in Auth0 Dashboard (Applications → Your App → Settings → Application URIs)
“PKCE not allowed” error
Fix:- Go to Auth0 Dashboard → Applications → Your Application
- Change application type to Native
- Save changes and try again
Prebuild fails or plugin not applied
Fix:iOS build fails with Pod errors
Fix:User cancelled error
Handle gracefully in your login function:iOS Alert Dialog
On iOS, users see a permission dialog: “App Name” Wants to Use “auth0.com” to Sign In. This is expected behavior fromASWebAuthenticationSession. Users must tap Continue to proceed.To customize this behavior, you can use ephemeral sessions (disables SSO):Retrieving Access Tokens
Retrieving Access Tokens
Use the
getCredentials() method to retrieve tokens for API calls:Check Authentication Status on App Launch
Check Authentication Status on App Launch
Use
hasValidCredentials() to check if the user is already logged in:Production Deployment with EAS Build
Production Deployment with EAS Build
For production builds, use EAS Build instead of local development builds.Install EAS CLI:Create Build for production:Configure Android App Links in Auth0 Dashboard:
eas.json in your project root:eas.json
Before deploying to production
Use HTTPS callback URLs for enhanced security:- Settings → Advanced Settings → Device Settings
- Add your app’s SHA-256 fingerprint
- Add Associated Domains capability in Xcode
- Add
webcredentials:{yourDomain}to Associated Domains
- Enable OIDC Conformant in Advanced Settings
- Configure Token Expiration appropriately
- Set up Brute Force Protection
- Test on multiple devices and OS versions
- Implement proper error handling for network failures