Skip to main content

Advanced configuration

All advanced SDK settings are configured in a web3authConfig.ts file and passed to Web3AuthProvider via the config prop. There is no constructor to call — the provider initialises the SDK automatically using the options you supply.

Configuration file

web3authConfig.ts
import {
CHAIN_NAMESPACES,
WEB3AUTH_NETWORK,
MFA_LEVELS,
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://rpc.ankr.com/eth_sepolia',
displayName: 'Ethereum Sepolia Testnet',
blockExplorerUrl: 'https://sepolia.etherscan.io',
ticker: 'ETH',
tickerName: 'Ethereum',
},
],
defaultChainId: '0xaa36a7',
// Optional advanced settings:
mfaLevel: MFA_LEVELS.DEFAULT,
sessionTime: 86400 * 7, // 7 days
enableLogging: false,
},
}

export default web3AuthConfig

web3AuthOptions parameter reference

ParameterRequiredDescription
clientIdYesYour project's Client ID from the Embedded Wallets dashboard.
networkYesSapphire network to use. Use WEB3AUTH_NETWORK.SAPPHIRE_DEVNET for development (allows localhost) and WEB3AUTH_NETWORK.SAPPHIRE_MAINNET for production.
redirectUrlYesDeep link URL that Web3Auth redirects to after authentication. Must be allowlisted in the dashboard under Allowed Origins.
chains?NoArray of CustomChainConfig objects defining the EVM or Solana chains your app supports. Replaces the v8 privateKeyProvider pattern. The SDK creates the appropriate provider automatically based on chainNamespace.
defaultChainId?NoHex chain ID string for the default active chain (for example, "0xaa36a7"). Defaults to the first entry in chains.
accountAbstractionConfig?NoSmart account configuration (AccountAbstractionMultiChainConfig). Set smartAccountType to "safe" or another supported provider to enable account abstraction. Set to null to disable.
walletServicesConfig?NoConfiguration for the Wallet Services in-app browser overlay. Controls confirmationStrategy and other embed parameters.
whiteLabel?NoCustom branding and UI options (WhiteLabelData). Applies to the authentication screens launched in the in-app browser.
mfaLevel?NoDefault MFA prompt behavior. Accepts MFA_LEVELS.DEFAULT, MFA_LEVELS.OPTIONAL, MFA_LEVELS.MANDATORY, or MFA_LEVELS.NONE.
sessionTime?NoSession duration in seconds. Minimum is 1; maximum is 86400 * 30 (30 days). Defaults to 86400 (1 day).
enableLogging?NoSet to true to print SDK debug logs to the console. Defaults to false.
walletSdkURL?NoOptional URL override for the Wallet Services embed. Leave unset to use the default production URL.

Chain configuration

Pass an array of CustomChainConfig objects to the chains field in web3AuthOptions. The SDK selects the appropriate EVM or Solana provider automatically based on chainNamespace.

import { CHAIN_NAMESPACES } 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://rpc.ankr.com/eth_sepolia',
displayName: 'Ethereum Sepolia',
blockExplorerUrl: 'https://sepolia.etherscan.io',
ticker: 'ETH',
tickerName: 'Ethereum',
},
],
defaultChainId: '0xaa36a7',
},
}

CHAIN_NAMESPACES

ConstantUse for
CHAIN_NAMESPACES.EIP155All EVM-compatible chains
CHAIN_NAMESPACES.SOLANASolana mainnet, devnet, testnet

Session management

Control how long users stay authenticated by setting sessionTime in web3AuthOptions:

  • Minimum: 1 second
  • Maximum: 86400 * 30 (30 days)
  • Default: 86400 (1 day)
web3AuthOptions: {
// ...
sessionTime: 86400 * 7, // 7 days
}

Advanced topics