Installation
Install the required peer dependencies:Basic usage
Standard modal (social login)
Custom authentication (Firebase, Auth0, etc.)
Configuration
Required options
Your Web3Auth client ID from the Web3Auth Dashboard.
Optional options
Web3Auth network to use:
mainnet: Production networktestnet: Test networksapphire_mainnet: Sapphire mainnet (recommended)sapphire_devnet: Sapphire development networkcyan: Cyan networkaqua: Aqua network
Specify a login provider to skip the modal:
google,facebook,twitter,discord,reddit,twitch,appleline,github,kakao,linkedin,weibo,wechatemail_passwordless,sms_passwordless
Pre-fill email or phone number for passwordless login.
Customize the Web3Auth modal appearance:
appName: Your app nameappUrl: Your app URLlogoLight: Light theme logo URLlogoDark: Dark theme logo URLdefaultLanguage: UI language codemode:'light','dark', or'auto'theme: Custom CSS variable overrides
Use popup flow instead of redirect flow.
Default verifier name for custom authentication. When set,
connect() can be called with just idToken and verifierId.Callback to get fresh authentication credentials when the session expires. Required for automatic re-authentication with Single Factor Auth (SFA).Returns:
idToken: JWT token from your auth providerverifierId: User identifier (email, uid, etc.)verifier?: Custom verifier name (optional, usesoptions.verifierif not provided)
Type definitions
Features
Social login
Users can authenticate with their existing social accounts (Google, Facebook, Twitter, etc.) without managing private keys directly.Custom authentication
Integrate with your existing authentication system (Firebase, Auth0, Cognito, etc.) using JWT tokens.Lazy authentication
Sessions are restored from cache without requiring immediate re-authentication. Web3Auth connection is deferred until signing is needed.Automatic re-authentication
WhengetAuthCredentials is configured, the wallet automatically re-authenticates when the session expires, providing a seamless user experience.
Private key access
The Web3Auth wallet supports thewithPrivateKey method for advanced use cases that require direct private key access:
Methods
connect()
Initiates Web3Auth connection. Opens the modal for social login or uses custom authentication. Parameters (optional):idToken?: JWT token for custom authenticationverifierId?: User identifier for custom authenticationverifier?: Custom verifier name (overridesoptions.verifier)
Promise<WalletAccount[]>
Examples:
disconnect()
Disconnects from Web3Auth and clears the session. Returns:Promise<void>
signTransactions()
Signs transactions using the Web3Auth-managed private key. Automatically re-authenticates if the session has expired. Parameters:txnGroup: Transaction or array of transactions to signindexesToSign?: Optional array of indexes to sign
Promise<(Uint8Array | null)[]>
withPrivateKey()
Provides scoped access to the private key via a callback. The key is fetched fresh from Web3Auth and automatically zeroed after use. Parameters:callback: Async function that receives the 64-byte Algorand secret key
Promise<T> - Returns the result of the callback
Security: The private key is never cached and is zeroed from memory immediately after the callback completes.
Session management
Web3Auth uses a sophisticated session management system:- Initial connection: User authenticates with social login or custom auth
- Caching: Address is cached in localStorage, private key is never stored
- Lazy restore: On app reload, cached address is restored without Web3Auth connection
- Deferred authentication: Web3Auth connection happens only when signing is needed
- Auto re-auth: If session expired, automatically re-authenticates using
getAuthCredentials
Security considerations
Key Security:
- Private keys are never persisted to localStorage
- Keys are fetched fresh from Web3Auth for each signing operation
- Keys are immediately cleared from memory after use
withPrivateKeyprovides controlled, time-limited access to keys
Platform support
- Web: Full support
- Mobile: Full support (mobile web)
- Desktop: Full support
Authentication flows
Social login flow
- User clicks connect
- Web3Auth modal opens
- User selects social provider and authenticates
- Web3Auth generates/retrieves the key shard
- Algorand address is derived and cached
Custom auth flow (SFA)
- User authenticates with your system (Firebase, Auth0, etc.)
- Your app gets JWT token
connect()called withidTokenandverifierId- Web3Auth Single Factor Auth generates/retrieves key shard
- Algorand address is derived and cached
Re-authentication flow
- User reloads app
- Address restored from cache (no Web3Auth connection yet)
- User attempts to sign transaction
- If session expired:
getAuthCredentials()called to get fresh JWT- Web3Auth reconnects with fresh credentials
- Address verified to match cached address
- Transaction signed