A complete React Native (Expo) sample demonstrating embedded wallet authentication with the Openfort SDK.
- Multiple Authentication Methods: Passkeys, OAuth (Google, Twitter, Discord, Apple), Email OTP, Guest
- Embedded Wallet Management: Create wallets with different recovery methods (automatic, password, passkey)
- Multi-chain Support: Base Sepolia and Ethereum Sepolia testnets
- Shield Integration: Secure wallet key encryption
- Node.js 18+
- pnpm package manager
- Openfort Account with API keys
- For passkeys: HTTPS domain (use ngrok for local development)
git clone https://github.com/openfort-xyz/react-native-auth-sample.git
cd react-native-auth-sample
pnpm installCopy the example environment file and fill in your credentials:
cp .env.example .envEdit .env with your values:
# Get from https://dashboard.openfort.io
SHIELD_API_KEY=your-shield-api-key
SHIELD_ENCRYPTION_SHARE=your-encryption-share
SHIELD_SECRET_KEY=your-shield-secret-key
# Android passkeys (see Passkeys section below)
ANDROID_PACKAGE_NAME=com.openfort.exposample
ANDROID_SHA256_FINGERPRINTS=your-sha256-fingerprint
# iOS passkeys (see Passkeys section below)
APPLE_TEAM_ID=your-apple-team-id
APPLE_BUNDLE_ID=com.openfort.exposampleUpdate app.json with your Openfort keys and domain:
{
"expo": {
"ios": {
"associatedDomains": ["webcredentials:your-domain.ngrok-free.app"]
},
"extra": {
"openfortPublishableKey": "pk_test_your-key",
"openfortShieldPublishableKey": "your-shield-publishable-key",
"passkeyRpId": "your-domain.ngrok-free.app",
"passkeyRpName": "Your App Name"
}
}
}With Passkeys (default): This project includes react-native-passkeys which requires a development build. You cannot use Expo Go.
# First time: create native builds
pnpm prebuild # Generate ios/ and android/ directories
pnpm build:ios # Build and run iOS (requires Xcode)
pnpm build:android # Build and run Android (requires Android Studio)
# After initial build: use Expo dev server for fast refresh
pnpm start # Start Expo dev server
pnpm ios # Start dev server + open iOS simulator
pnpm android # Start dev server + open Android emulator
# If you change native config (app.json plugins, etc.):
pnpm prebuild:clean # Regenerate native directoriesWithout Passkeys (Expo Go compatible): If you don't need passkey authentication, you can remove react-native-passkeys from dependencies and use Expo Go with just pnpm start. OAuth, Email OTP, and Guest authentication will still work.
Passkeys require HTTPS. For local development, use ngrok to create a tunnel:
# Start Expo on port 8081
npx expo start --port 8081
# In another terminal, start ngrok
ngrok http 8081Use the ngrok URL (e.g., abc123.ngrok-free.app) for your passkeyRpId and associatedDomains.
-
Get your Team ID from the Apple Developer Portal
-
Set in
.env:APPLE_TEAM_ID=YOUR_TEAM_ID APPLE_BUNDLE_ID=com.openfort.exposample
-
Update
app.jsonwith your domain:{ "ios": { "associatedDomains": ["webcredentials:your-domain.ngrok-free.app"] } } -
Rebuild:
npx expo prebuild -p ios --clean && pnpm ios -
Verify:
curl https://your-domain.ngrok-free.app/.well-known/apple-app-site-association
-
Get your debug keystore SHA256 fingerprint:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android | grep SHA256
-
Set in
.env:ANDROID_PACKAGE_NAME=com.openfort.exposample ANDROID_SHA256_FINGERPRINTS=FA:C6:17:45:...your-fingerprint
-
Rebuild:
npx expo prebuild -p android --clean && pnpm android -
Verify:
curl https://your-domain.ngrok-free.app/.well-known/assetlinks.json
app/
├── _layout.tsx # Root layout with OpenfortProvider
├── (auth)/ # Authentication routes
│ ├── _layout.tsx # Auth guard (redirects if logged in)
│ ├── auth.tsx # Login screen
│ └── email-otp.tsx # Email OTP flow
├── (app)/ # Protected routes
│ └── index.tsx # User dashboard
├── .well-known/ # Passkey verification endpoints
│ ├── assetlinks.json+api.ts
│ └── apple-app-site-association+api.ts
└── api/
└── protected-create-encryption-session+api.ts
components/
├── LoginScreen.tsx # Auth method selection
└── UserScreen.tsx # Wallet management dashboard
| Method | Description |
|---|---|
| Passkey | Biometric/device authentication via WebAuthn |
| OAuth | Google, Twitter, Discord, Apple sign-in |
| Email OTP | Email verification with one-time password |
| Guest | Anonymous authentication for quick testing |
| Method | Description |
|---|---|
| Automatic | SDK-managed recovery, no user input |
| Password | User-provided password for recovery |
| Passkey | Biometric-based recovery |