useWeb3Auth
Hook to access the Web3Auth context.
Import
import { useWeb3Auth } from '@web3auth/modal/react'
Usage
import { useWeb3Auth } from '@web3auth/modal/react'
function App() {
const { web3Auth, isConnected, isInitializing, connection, status, initError } = useWeb3Auth()
if (isConnected) {
console.log('Connected via:', connection?.connectorName)
}
if (isInitializing) {
console.log('Web3Auth is initializing')
}
if (connection?.ethereumProvider) {
// Use for JSON-RPC edge cases; prefer Wagmi hooks for standard EVM flows
console.log('Ethereum provider available')
}
if (status) {
console.log('Web3Auth status:', status)
}
if (initError) {
console.log('Web3Auth initialization error:', initError)
}
}
For EVM wallet operations, use Wagmi hooks (useConnection, useBalance,
useSendTransaction) after setting up WagmiProvider.
Use connection.ethereumProvider only for JSON-RPC methods Wagmi does not cover.
See the Web SDK v11 migration guide.
Return type
import { type IUseWeb3Auth } from '@web3auth/modal/react'
connection
{ ethereumProvider, solanaWallet, connectorName } | null
Active wallet connection after sign-in. ethereumProvider is an EIP-1193 provider for EVM;
solanaWallet exposes Solana wallet utilities.
initError
Error | null
Error that occurred during Web3Auth initialization.
isConnected
boolean
Whether the user is connected to Web3Auth.
isInitialized
boolean
Whether Web3Auth has completed initialization.
isInitializing
boolean
Whether Web3Auth is currently initializing.
status
string
Current status of the Web3Auth connection.
web3Auth
Web3Auth
The Web3Auth instance.
getPlugin
(pluginName: PLUGIN_NAME) => IPlugin | null
Helper function to get a plugin by name.