{"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.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install react-native-auth0"],"cli":null},"imports":["import Auth0 from 'react-native-auth0';","import { useAuth0 } from 'react-native-auth0';","import { AuthError } from 'react-native-auth0';"],"auth":{"required":false,"env_vars":[]},"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()`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}