{"id":15195,"library":"react-native-auth0","title":"Auth0 SDK for React Native","description":"Auth0 SDK for React Native provides a comprehensive toolkit for integrating Auth0 authentication and authorization into React Native applications, supporting iOS, Android, and React Native Web. It is currently on stable version 5.5.0 and maintains an active release cadence with frequent minor and patch updates to introduce new features (e.g., DPoP, MRRT, Custom Token Exchange) and fix issues. Key differentiators include full support for the React Native New Architecture and Expo 53+, abstracting complex OAuth/OIDC flows, and robust handling of token management, silent authentication, and user sessions. The library aims to simplify secure authentication implementation across diverse mobile platforms.","status":"active","version":"5.5.0","language":"javascript","source_language":"en","source_url":"https://github.com/auth0/react-native-auth0","tags":["javascript","react-native","ios","android","typescript"],"install":[{"cmd":"npm install react-native-auth0","lang":"bash","label":"npm"},{"cmd":"yarn add react-native-auth0","lang":"bash","label":"yarn"},{"cmd":"pnpm add react-native-auth0","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for React Native component integration.","package":"react","optional":false},{"reason":"Peer dependency required for React Native application development.","package":"react-native","optional":false}],"imports":[{"note":"The primary `Auth0` class is exported as a default export since v5, and needs to be instantiated before use.","wrong":"import { Auth0 } from 'react-native-auth0';","symbol":"Auth0","correct":"import Auth0 from 'react-native-auth0';"},{"note":"A named export hook for consuming Auth0 context within functional components, if available or implemented via a wrapper.","wrong":"import useAuth0 from 'react-native-auth0';","symbol":"useAuth0","correct":"import { useAuth0 } from 'react-native-auth0';"},{"note":"The custom error class exported for type checking and handling specific Auth0 SDK errors. Exported from main entry point since v5.0.1.","wrong":"const AuthError = require('react-native-auth0').AuthError;","symbol":"AuthError","correct":"import { AuthError } from 'react-native-auth0';"}],"quickstart":{"code":"import React, { useState } from 'react';\nimport { Button, Text, View, StyleSheet, Alert } from 'react-native';\nimport Auth0 from 'react-native-auth0';\n\n// Ensure these are set in your .env or similar configuration\nconst AUTH0_DOMAIN = process.env.AUTH0_DOMAIN ?? 'YOUR_AUTH0_DOMAIN.auth0.com';\nconst AUTH0_CLIENT_ID = process.env.AUTH0_CLIENT_ID ?? 'YOUR_AUTH0_CLIENT_ID';\nconst AUTH0_AUDIENCE = process.env.AUTH0_AUDIENCE ?? 'YOUR_API_AUDIENCE'; // Optional\n\nconst auth0 = new Auth0({\n  domain: AUTH0_DOMAIN,\n  clientId: AUTH0_CLIENT_ID,\n});\n\nexport default function Auth0Quickstart() {\n  const [accessToken, setAccessToken] = useState<string | null>(null);\n\n  const login = async () => {\n    try {\n      const credentials = await auth0.webAuth.authorize({\n        scope: 'openid profile email offline_access',\n        audience: AUTH0_AUDIENCE,\n      });\n      setAccessToken(credentials.accessToken);\n      Alert.alert('Success', `Logged in! Token starts with: ${credentials.accessToken.substring(0, 10)}...`);\n    } catch (e: any) {\n      console.error('Login failed:', e);\n      Alert.alert('Login Error', e.message || 'An unknown error occurred during login.');\n    }\n  };\n\n  const logout = async () => {\n    try {\n      await auth0.webAuth.clearSession({});\n      setAccessToken(null);\n      Alert.alert('Success', 'Logged out.');\n    } catch (e: any) {\n      console.error('Logout failed:', e);\n      Alert.alert('Logout Error', e.message || 'An unknown error occurred during logout.');\n    }\n  };\n\n  return (\n    <View style={styles.container}>\n      <Text style={styles.header}>Auth0 React Native Integration</Text>\n      {accessToken ? (\n        <View>\n          <Text style={styles.statusText}>You are logged in!</Text>\n          <Button title=\"Log Out\" onPress={logout} />\n        </View>\n      ) : (\n        <View>\n          <Text style={styles.statusText}>You are logged out.</Text>\n          <Button title=\"Log In\" onPress={login} />\n        </View>\n      )}\n    </View>\n  );\n}\n\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    justifyContent: 'center',\n    alignItems: 'center',\n    padding: 20,\n    backgroundColor: '#f5f5f5',\n  },\n  header: {\n    fontSize: 24,\n    fontWeight: 'bold',\n    marginBottom: 40,\n    color: '#333',\n  },\n  statusText: {\n    fontSize: 18,\n    marginBottom: 20,\n    textAlign: 'center',\n    color: '#555',\n  },\n});\n","lang":"typescript","description":"Demonstrates initializing the Auth0 client, performing an interactive login via `webAuth.authorize()`, retrieving the access token, and clearing the session with `webAuth.clearSession()`."},"warnings":[{"fix":"Consult the official 'Migration Guide' on the GitHub repository for detailed instructions on upgrading to v5.x, especially regarding the instantiation of the `Auth0` client.","message":"Version 5.0.0 introduced a complete architectural refactor, including breaking changes to the API surface. Applications upgrading from v4.x or earlier will require significant code changes.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Ensure your project meets these minimum version requirements before upgrading. If using an older Expo version (less than 53), you must use `react-native-auth0` v4.x or earlier.","message":"The minimum peer dependencies for `react-native-auth0` v5.0.0+ were updated to React 19.0.0+, React Native 0.78.0+, and Expo 53+.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Update your project's `ios/Podfile` to `platform :ios, '14.0'`.","message":"The SDK requires a minimum iOS deployment target of 14.0. Failure to set this in your Podfile will result in build errors.","severity":"gotcha","affected_versions":">=5.0.0"},{"fix":"Upgrade to `react-native-auth0` v5.0.1 or newer to correctly import `AuthError` as a named export: `import { AuthError } from 'react-native-auth0';`.","message":"The `AuthError` class was not exported from the main entry point in v5.0.0, leading to potential import issues if trying to access it directly.","severity":"gotcha","affected_versions":"5.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"In v5.x, you must instantiate the Auth0 client: `const auth0 = new Auth0({ domain, clientId });` and then use `auth0.webAuth.authorize()`.","cause":"Attempting to use `Auth0.webAuth.authorize()` statically or on a pre-v5 global Auth0 object after upgrading to v5.x.","error":"TypeError: Cannot read properties of undefined (reading 'authorize')"},{"fix":"Carefully 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`.","cause":"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).","error":"Invalid redirect URI"},{"fix":"Ensure `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`.","cause":"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.","error":"Could not find a declaration file for module 'react-native-auth0'."}],"ecosystem":"npm"}