Advanced configuration
Configure the SDK in web3authConfig.ts and pass it to Web3AuthProvider through the config prop. The provider initializes the SDK with these options. Most settings can also be set on the dashboard; options you pass in code are merged with the dashboard settings.
Configuration file
import {
CHAIN_NAMESPACES,
WEB3AUTH_NETWORK,
type Web3AuthContextConfig,
} from '@web3auth/react-native-sdk'
const web3AuthConfig: Web3AuthContextConfig = {
web3AuthOptions: {
clientId: 'YOUR_CLIENT_ID', // from developer.metamask.io
redirectUrl: 'yourapp://auth',
network: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
chains: [
{
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: '0xaa36a7',
rpcTarget: 'https://ethereum-sepolia-rpc.publicnode.com',
displayName: 'Ethereum Sepolia Testnet',
blockExplorerUrl: 'https://sepolia.etherscan.io',
ticker: 'ETH',
tickerName: 'Ethereum',
},
],
defaultChainId: '0xaa36a7',
// Optional advanced settings:
sessionTime: 86400 * 7, // 7 days
enableLogging: false,
},
}
export default web3AuthConfig
web3AuthOptions reference
- Parameters
- Interface
| Parameter | Required | Description |
|---|---|---|
clientId | Yes | Client ID of your project on the Embedded Wallets dashboard. |
redirectUrl | Yes | Deep link the in-app browser returns to after sign-in, for example yourapp://auth. Must be allowlisted on the dashboard. |
network | Yes | WEB3AUTH_NETWORK.SAPPHIRE_MAINNET or WEB3AUTH_NETWORK.SAPPHIRE_DEVNET. Must match the network of your dashboard project. |
chains | No | Array of CustomChainConfig objects. Merged with the chains configured on the dashboard; entries with the same chainId override the dashboard values. Initialization fails if no chains are configured in either place. |
defaultChainId | No | Hex chain ID of the chain to use after sign-in. If not set, the SDK uses the first chain in the merged list. Dashboard chains come first in that list, so set defaultChainId if you configure chains both on the dashboard and in code. |
accountAbstractionConfig | No | Smart account configuration, merged with the dashboard smart account settings. Set to null to turn off smart accounts that are enabled on the dashboard. |
useAAWithExternalWallet | No | Whether to use smart accounts with external wallets. If not set, the SDK uses the dashboard wallet scope setting. |
walletServicesConfig | No | Wallet Services settings, such as confirmationStrategy ('default', 'auto-approve', or 'modal'), enableKeyExport, and whiteLabel. Overrides the dashboard Wallet UI settings. |
whiteLabel | No | Branding for the sign-in screens. Merged with the dashboard branding settings. See Whitelabel. |
mfaSettings | No | MFA factor configuration. See Multi-factor authentication. |
sessionTime | No | Session duration in seconds. If not set, the SDK uses the session duration configured on the dashboard (30 days by default). |
authConnectionConfig | No | Additional auth connection definitions, merged with the connections configured on the dashboard. |
useCoreKitKey | No | Use the Core Kit key instead of the default key. Only set this if you migrate users from a Core Kit integration. |
enableLogging | No | Print SDK debug logs. The default is false. |
disableAnalytics | No | Turn off the anonymous usage analytics that the SDK sends. The default is false. |
walletSdkURL | No | Override the Wallet Services URL, for example to point at a staging deployment. If not set, the SDK picks the URL for buildEnv (production by default). |
// Simplified. See SdkInitParams in @web3auth/react-native-sdk for the full type.
interface SdkInitParams {
clientId: string
redirectUrl: string
network: WEB3AUTH_NETWORK_TYPE
chains?: CustomChainConfig[]
defaultChainId?: string
accountAbstractionConfig?: AccountAbstractionMultiChainConfig | null
useAAWithExternalWallet?: boolean
walletServicesConfig?: WalletServicesConfig
whiteLabel?: WhiteLabelData
mfaSettings?: MfaSettings
sessionTime?: number
authConnectionConfig?: AuthConnectionConfig
useCoreKitKey?: boolean
enableLogging?: boolean
disableAnalytics?: boolean
walletSdkURL?: string
buildEnv?: BUILD_ENV_TYPE
}
Chain configuration
Pass an array of CustomChainConfig objects to the chains field in web3AuthOptions. After sign-in, the SDK exposes connection.ethereumProvider for CHAIN_NAMESPACES.EIP155 chains and connection.solanaWallet for CHAIN_NAMESPACES.SOLANA chains, based on the active chain. Solana chains must use the chain IDs 0x65 (Mainnet), 0x66 (Testnet), or 0x67 (Devnet).
- EVM chain
- Solana chain
- Interface
import { CHAIN_NAMESPACES, WEB3AUTH_NETWORK } from '@web3auth/react-native-sdk'
const web3AuthConfig = {
web3AuthOptions: {
clientId: 'YOUR_CLIENT_ID',
redirectUrl: 'yourapp://auth',
network: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
chains: [
{
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: '0xaa36a7', // Ethereum Sepolia
rpcTarget: 'https://ethereum-sepolia-rpc.publicnode.com',
displayName: 'Ethereum Sepolia',
blockExplorerUrl: 'https://sepolia.etherscan.io',
ticker: 'ETH',
tickerName: 'Ethereum',
},
],
defaultChainId: '0xaa36a7',
},
}
import { CHAIN_NAMESPACES, WEB3AUTH_NETWORK } from '@web3auth/react-native-sdk'
const web3AuthConfig = {
web3AuthOptions: {
clientId: 'YOUR_CLIENT_ID',
redirectUrl: 'yourapp://auth',
network: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
chains: [
{
chainNamespace: CHAIN_NAMESPACES.SOLANA,
chainId: '0x67', // Solana Devnet (0x65 Mainnet, 0x66 Testnet)
rpcTarget: 'https://api.devnet.solana.com',
displayName: 'Solana Devnet',
blockExplorerUrl: 'https://explorer.solana.com?cluster=devnet',
ticker: 'SOL',
tickerName: 'Solana',
logo: 'https://images.toruswallet.io/solana.svg',
},
],
defaultChainId: '0x67',
},
}
export interface CustomChainConfig {
/** Chain namespace: CHAIN_NAMESPACES.EIP155 for EVM, CHAIN_NAMESPACES.SOLANA for Solana */
chainNamespace: ChainNamespaceType
/** Chain ID as a hex string (for example, "0x1" for Ethereum mainnet) */
chainId: string
/** JSON-RPC endpoint URL for this chain */
rpcTarget: string
/** Human-readable chain name shown in the UI */
displayName?: string
/** Block explorer base URL */
blockExplorerUrl?: string
/** Native token ticker symbol (for example, "ETH") */
ticker?: string
/** Native token full name (for example, "Ethereum") */
tickerName?: string
/** Token logo URL */
logo?: string
/** WebSocket endpoint URL (optional) */
wsTarget?: string
}
CHAIN_NAMESPACES
| Constant | Use for |
|---|---|
CHAIN_NAMESPACES.EIP155 | All EVM-compatible chains |
CHAIN_NAMESPACES.SOLANA | Solana mainnet, devnet, testnet |
Session management
Set sessionTime in web3AuthOptions to control how long users stay signed in, in seconds. If you
don't set it, the SDK uses the session duration configured on the dashboard (30 days by default).
web3AuthOptions: {
// ...
sessionTime: 86400 * 7, // 7 days
}
Advanced topics
- Custom authentication, configure social login connections and custom JWT flows
- Smart accounts, enable account abstraction
- Whitelabeling, customize authentication UI branding
- Multi-Factor Authentication, control MFA prompts and factor configuration
- Dapp share, how the SDK stores the dapp share for MFA-enabled wallets