Shows how to use Auth0 as a Custom Connection (bring-your-own-OAuth) with MetaMask Embedded Wallets in a bare React Native app.
The SDK handles the entire OAuth flow via an in-app browser — no react-native-auth0 dependency is required. You configure the Auth0 tenant once in the Web3Auth Dashboard, and the SDK brokers the login transparently.
- Configuring a Custom Connection (
AUTH_CONNECTION.CUSTOM) backed by Auth0 - Full split structure:
LoginView,HomeView,Console,lib/evm.ts— each file has one job - The SDK-native approach (no external Auth0 library)
- Wallet Services overlay for signing, MFA, and Wallet UI
- Session persistence with
react-native-encrypted-storage
| File | What it does |
|---|---|
web3authConfig.ts |
The only file you edit — Client ID, redirect URL, network, chain config |
lib/evm.ts |
Pure EVM helpers (getAddress, getBalance, signMessage) — no React |
components/LoginView.tsx |
Single "Login with Auth0" button → connectTo({ authConnection: CUSTOM, authConnectionId }) |
components/HomeView.tsx |
All post-login actions — blockchain calls, wallet UI, MFA, disconnect |
components/Console.tsx |
Dumb scrollable output box — <Console output={...} /> |
App.tsx |
<Web3AuthProvider> + Screen component that switches between Login/Home |
index.js |
Entry point — @web3auth/react-native-sdk/setup must be the very first import |
metro.config.js |
withWeb3Auth() sets up all polyfill aliases |
- React Native
0.74.x(bare workflow) @web3auth/react-native-sdk^9.0.0ethers^6.x@toruslabs/react-native-web-browserreact-native-encrypted-storage
- Node.js
>=18, React Native CLI environment, Xcode / Android Studio - A Web3Auth Dashboard project with an Auth0 Custom Connection configured
- Create a project at dashboard.web3auth.io.
- Under Connections, create a Custom Connection with:
- Auth type:
JWT - Auth0 domain:
https://web3auth.au.auth0.com - Connection ID:
w3a-auth0-demo(used asauthConnectionIdin code) - Verifier ID field:
sub
- Auth type:
- Under Allowed Origins, add:
web3authrnbareauth0example://auth - Copy the Client ID into
web3authConfig.ts.
cd rn-bare-auth0-example
npm install
# iOS
cd ios && pod install && cd ..npm start # Metro bundler
npm run ios # iOS simulator
npm run android # Android emulator// The SDK opens Auth0's login page in an in-app browser and derives the key.
// No react-native-auth0 required.
connectTo({
authConnection: AUTH_CONNECTION.CUSTOM,
authConnectionId: "w3a-auth0-demo", // your Dashboard Connection ID
extraLoginOptions: {
domain: "https://web3auth.au.auth0.com",
verifierIdField: "sub",
},
});const { provider } = useWeb3Auth(); // EIP-1193 provider, use directly with ethers
const address = await getAddress(provider!);
const balance = await getBalance(provider!);const { request } = useSignatureRequest();
const sig = await request("personal_sign", ["Hello Web3Auth!", "0x"]);OAuth redirect not working — Confirm web3authrnbareauth0example://auth is in the Dashboard's Allowed Origins, and the scheme appears in AndroidManifest.xml and Info.plist.
Metro errors — See Metro Polyfill Troubleshooting.
MIT — see LICENSE.