Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Auth0
✓ import Auth0 from 'react-native-auth0';
✗ import { Auth0 } from 'react-native-auth0';
The primary `Auth0` class is exported as a default export since v5, and needs to be instantiated before use.
useAuth0
✓ import { useAuth0 } from 'react-native-auth0';
✗ import useAuth0 from 'react-native-auth0';
A named export hook for consuming Auth0 context within functional components, if available or implemented via a wrapper.
AuthError
✓ import { AuthError } from 'react-native-auth0';
✗ const AuthError = require('react-native-auth0').AuthError;
The custom error class exported for type checking and handling specific Auth0 SDK errors. Exported from main entry point since v5.0.1.
Demonstrates initializing the Auth0 client, performing an interactive login via `webAuth.authorize()`, retrieving the access token, and clearing the session with `webAuth.clearSession()`.
import React, { useState } from 'react';
import { Button, Text, View, StyleSheet, Alert } from 'react-native';
import Auth0 from 'react-native-auth0';
// Ensure these are set in your .env or similar configuration
const AUTH0_DOMAIN = process.env.AUTH0_DOMAIN ?? 'YOUR_AUTH0_DOMAIN.auth0.com';
const AUTH0_CLIENT_ID = process.env.AUTH0_CLIENT_ID ?? 'YOUR_AUTH0_CLIENT_ID';
const AUTH0_AUDIENCE = process.env.AUTH0_AUDIENCE ?? 'YOUR_API_AUDIENCE'; // Optional
const auth0 = new Auth0({
domain: AUTH0_DOMAIN,
clientId: AUTH0_CLIENT_ID,
});
export default function Auth0Quickstart() {
const [accessToken, setAccessToken] = useState<string | null>(null);
const login = async () => {
try {
const credentials = await auth0.webAuth.authorize({
scope: 'openid profile email offline_access',
audience: AUTH0_AUDIENCE,
});
setAccessToken(credentials.accessToken);
Alert.alert('Success', `Logged in! Token starts with: ${credentials.accessToken.substring(0, 10)}...`);
} catch (e: any) {
console.error('Login failed:', e);
Alert.alert('Login Error', e.message || 'An unknown error occurred during login.');
}
};
const logout = async () => {
try {
await auth0.webAuth.clearSession({});
setAccessToken(null);
Alert.alert('Success', 'Logged out.');
} catch (e: any) {
console.error('Logout failed:', e);
Alert.alert('Logout Error', e.message || 'An unknown error occurred during logout.');
}
};
return (
<View style={styles.container}>
<Text style={styles.header}>Auth0 React Native Integration</Text>
{accessToken ? (
<View>
<Text style={styles.statusText}>You are logged in!</Text>
<Button title="Log Out" onPress={logout} />
</View>
) : (
<View>
<Text style={styles.statusText}>You are logged out.</Text>
<Button title="Log In" onPress={login} />
</View>
)}
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: 20,
backgroundColor: '#f5f5f5',
},
header: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 40,
color: '#333',
},
statusText: {
fontSize: 18,
marginBottom: 20,
textAlign: 'center',
color: '#555',
},
});
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'authorize')
Attempting to use `Auth0.webAuth.authorize()` statically or on a pre-v5 global Auth0 object after upgrading to v5.x.
fixIn v5.x, you must instantiate the Auth0 client: `const auth0 = new Auth0({ domain, clientId });` and then use `auth0.webAuth.authorize()`. Invalid redirect URI
The callback URL configured in your Auth0 application settings does not exactly match the one generated by `react-native-auth0` for your specific platform (iOS bundle ID or Android package name).
fixCarefully follow the SDK configuration steps for Android, iOS, or Expo. Ensure your Auth0 application's 'Allowed Callback URLs' are correctly set, e.g., `APP_BUNDLE_IDENTIFIER://YOUR_AUTH0_DOMAIN/ios/APP_BUNDLE_IDENTIFIER/callback`.
Could not find a declaration file for module 'react-native-auth0'.
TypeScript compiler is unable to locate the type definitions for the `react-native-auth0` package. This might happen due to incorrect `tsconfig.json` setup or issues with module resolution.
fixEnsure `react-native-auth0` is correctly installed and your `tsconfig.json` includes `node_modules` in its `typeRoots` or `include` paths. If the problem persists, try updating TypeScript or reinstalling `node_modules`.
Audit
Dependencies
reactrequiredPeer dependency required for React Native component integration.
react-nativerequiredPeer dependency required for React Native application development.