Skip to main content

Advanced Configuration

The Web3Auth SDK provides extensive configuration options that allow you to customize authentication flows, UI appearance, blockchain integrations, and security features to meet your application's specific requirements.

Configuration Structure

When setting up Web3Auth, you'll pass in the options to the constructor. This consists of:

import Web3Auth

web3Auth = Web3Auth(W3AInitParams(
clientId: "YOUR_CLIENT_ID", // Get your Client ID from Web3Auth Dashboard
network: .sapphire_mainnet, // or .sapphire_devnet
redirectUrl: "com.yourapp.bundleid://auth"
))

W3AInitParams

The Web3Auth Constructor takes an object with W3AInitParams as input.

ParameterDescription
clientIdYour Web3Auth Client ID from the Dashboard. It's a mandatory field of type String.
networkWeb3Auth Network: .sapphire_mainnet, .sapphire_devnet, .mainnet, .cyan, .aqua or .testnet. Mandatory field of type Network.
redirectUrlURL that Web3Auth will redirect API responses upon successful authentication. It's a mandatory field of type String.
whiteLabel?WhiteLabel options for custom UI, branding, and translations. Takes W3AWhiteLabelData as a value.
loginConfig?Login config for custom verifiers. Takes [String: W3ALoginConfig] as a value.
mfaSettings?Configure MFA settings for authentication. Takes MfaSettings as a value.
sessionTime?Configure session management time in seconds. Default is 86400 seconds (1 day). Max 30 days.

Session Management

Control how long users stay authenticated and how sessions persist. The session key is stored in the device's encrypted Keychain.

Key Configuration Options:

  • sessionTime - Session duration in seconds. Controls how long users remain authenticated before needing to log in again.
    • Minimum: 1 second (1).
    • Maximum: 30 days (86400 * 30).
    • Default: 7 days (86400 * 7).
web3Auth = Web3Auth(W3AInitParams(
clientId: "YOUR_CLIENT_ID", // Get your Client ID from Web3Auth Dashboard
network: .sapphire_mainnet, // or .sapphire_devnet
sessionTime: 86400 * 7, // 7 days (in seconds)
redirectUrl: "com.yourapp.bundleid://auth"
))

Custom Authentication Methods

Control the login options presented to your users. For detailed configuration options and implementation examples, see the Custom Authentication section.

UI Customization

Create a seamless brand experience by customizing the Web3Auth Login Screens to match your application's design. For complete customization options, refer to the Whitelabeling & UI Customization section.

Multi-Factor Authentication (MFA)

Add additional security layers to protect user accounts with two-factor authentication. For detailed configuration options and implementation examples, see the Multi-Factor Authentication section.

Key Configuration Options:

  • mfaSettings - Configure MFA settings for different authentication flows
  • mfaLevel - Control when users are prompted to set up MFA