Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@ To run the example application inside the repository, follow these steps:

The application will be built and launched on the specified platform, allowing you to interact with it.

To run the web example, run `yarn web` from the `example` directory and open the served URL.

### Layout

The app has no navigation. `App.tsx` (native) renders a single sectioned
`ScrollView`, one section per SDK feature group: Web Auth, Credentials Manager,
Direct Auth API (native only), Passwordless (native only), MFA, My Account,
Passkeys, and Advanced Tokens. `App.web.tsx` is a single file covering the
web-supported features only, with web-specific methods labelled inline.

Each native feature has two files under `src/features/`:

- `FeatureHooks.tsx` — the `useAuth0()` hooks approach. These are the files the
app actually imports and renders.
- `FeatureClass.tsx` — the same feature written against the `Auth0` class
instance (`src/shared/api.ts`), kept as unused side-by-side reference. Nothing
imports these; they exist to show the class API next to the hooks API.

Platform-specific methods carry the platform in their label (e.g.
`resumeSession (Android)`, `cancelWebAuth (iOS)`, `saveCredentials (Native only)`).
There is no custom styling — only default React Native components with spacing.

### To run on different Auth0 Application

1. Change the `clientId` and `domain` value in `example/src/auth0-configuration.js`
Expand Down
5 changes: 0 additions & 5 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@
"build:ios": "react-native build-ios --mode Debug"
},
"dependencies": {
"@react-navigation/bottom-tabs": "^7.18.15",
"@react-navigation/native": "^7.3.15",
"@react-navigation/stack": "^7.10.20",
"react": "19.2.8",
"react-native": "0.86.2",
"react-native-gesture-handler": "^3.0.2",
"react-native-safe-area-context": "^5.8.1",
"react-native-screens": "^4.27.0",
"react-native-web": "^0.21.2"
},
"devDependencies": {
Expand Down
54 changes: 40 additions & 14 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,49 @@
import React from 'react';
import { StatusBar } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import RootNavigator from './navigation/RootNavigator';
import { ScrollView, StatusBar, Text, View } from 'react-native';
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
import { Auth0Provider } from 'react-native-auth0';
import config from './auth0-configuration';

/**
* The absolute root component of the example application.
*
* It sets up the main navigation container and renders the RootNavigator,
* which then decides which demo flow (Hooks or Class-based) to display.
* The Auth0Provider is now scoped within the Hooks demo flow itself.
*/
import WebAuthHooks from './features/WebAuthHooks';
import CredentialsHooks from './features/CredentialsHooks';
import DirectAuthHooks from './features/DirectAuthHooks';
import PasswordlessHooks from './features/PasswordlessHooks';
import MfaHooks from './features/MfaHooks';
import MyAccountHooks from './features/MyAccountHooks';
import PasskeysHooks from './features/PasskeysHooks';
import AdvancedTokensHooks from './features/AdvancedTokensHooks';

// Native example app. Every feature is demonstrated with the hooks approach
// (wired up below). A matching *Class.tsx file sits next to each feature file
// showing the same feature with the Auth0 class instance as unused reference.
//
// Biometric-protected credentials can be enabled by passing
// localAuthenticationOptions to Auth0Provider, e.g.:
// <Auth0Provider domain={...} clientId={...} localAuthenticationOptions={{
// title: 'Authenticate', evaluationPolicy: LocalAuthenticationStrategy.deviceOwnerWithBiometrics,
// }}>
function App(): React.JSX.Element {
return (
<SafeAreaProvider>
<NavigationContainer>
<Auth0Provider domain={config.domain} clientId={config.clientId}>
<StatusBar barStyle="dark-content" />
<RootNavigator />
</NavigationContainer>
<SafeAreaView style={{ flex: 1 }}>
<ScrollView contentContainerStyle={{ padding: 16, gap: 24 }}>
<Text style={{ fontSize: 20, fontWeight: 'bold' }}>
react-native-auth0 example
</Text>
<WebAuthHooks />
<CredentialsHooks />
<DirectAuthHooks />
<PasswordlessHooks />
<MfaHooks />
<MyAccountHooks />
<PasskeysHooks />
<AdvancedTokensHooks />
<View style={{ height: 40 }} />
</ScrollView>
</SafeAreaView>
</Auth0Provider>
</SafeAreaProvider>
);
}
Expand Down
Loading
Loading