For AI agents: a documentation index is available at /llms.txt. A markdown version of this page is available at the same URL with .md appended (or via Accept: text/markdown).
Skip to main content

Advanced configuration

The Web3Auth by MetaMask, Embedded Wallet 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 Embedded Wallets, you'll pass in the options to the constructor. This consists of:

import { Web3Auth, WEB3AUTH_NETWORK } from '@web3auth/modal'

const web3auth = new Web3Auth({
clientId: 'YOUR_WEB3AUTH_CLIENT_ID',
web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
})

await web3auth.init()

Web3AuthOptions​

ParameterDescription
clientId(Mandatory) Client ID, available from the Embedded Wallets dashboard.
web3AuthNetwork(Mandatory) Web3Auth network to use for the session and the issued idToken, for example sapphire_mainnet or sapphire_devnet.
enableLogging?Setting to true enables logs. Default is false.
sessionTime?Session Time (in seconds) for idToken issued by Web3Auth for server side verification. If not set, the SDK uses the session time configured on the dashboard, then falls back to 30 days (30 * 86400). Max value can be 30 days (86400 * 30) and min can be 1 sec (1)
useSFAKey?Uses Single Factor Auth SDK key with Web3Auth provider. Default is false.
storage?Custom storage adapters for auth tokens (sessionId, accessToken, refreshToken, idToken). Default is localStorage-based adapters.
cookieOptions?Cookie configuration used when storage adapters are cookie-based.
defaultChainId?Default chain ID to use. Your first chain will be used as default.
multiInjectedProviderDiscovery?Whether to enable discovery of injected wallets in the browser. Default is true.

Session management​

Control how long users stay authenticated and how sessions persist.

Key Configuration Options:

  • sessionTime - Session duration in seconds. Controls how long users remain authenticated before needing to sign in again.
    • Minimum: 1 second (1).
    • Maximum: 30 days (86400 * 30).
    • Default: the session time configured on the dashboard. If none is set, the SDK uses 30 days (86400 * 30).
  • storage - Custom storage adapters for auth tokens (sessionId, accessToken, refreshToken, idToken). By default, the SDK uses localStorage-based adapters. When ssr is true and no custom sessionId adapter is set, the SDK stores its state in cookies.
  • cookieOptions - Cookie configuration used when storage adapters are cookie-based.
const web3AuthOptions = {
clientId: 'YOUR_WEB3AUTH_CLIENT_ID', // Pass your Web3Auth Client ID, ideally using an environment variable
web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,

// Session configuration
sessionTime: 86400 * 7, // 7 days (in seconds)
}

Multi-Factor Authentication​

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

Custom authentication methods​

Control the sign-in options presented to your users and how they're displayed in the modal. For detailed configuration options and implementation examples, see the custom authentication section.

Key Configuration Options:

  • modalConfig - Define which authentication methods are available and customize their appearance

UI customization​

Customize the brand experience by customizing the Web3Auth Modal to match your application's design. For complete customization options, refer to the Whitelabeling and UI Customization section.

Key Configuration Options:

  • uiConfig - Personalize the modal's look and feel with custom colors, logos, themes, and more
  • modalConfig - Control the visibility and arrangement of authentication options

Smart accounts (account abstraction)​

Improve user experience with gasless transactions and advanced account features. Learn more in the smart accounts documentation.

Key Configuration Options:

  • accountAbstractionConfig - Fine-tune parameters for smart account implementation
  • useAAWithExternalWallet - Enable account abstraction functionality even when users connect with external wallets

Wallet Services​

Extend your application with enhanced wallet functionality. See the Wallet Services documentation for complete configuration options.

Key Configuration Options:

  • walletServicesConfig - Integrate additional Wallet Services and features