Actions
caution
This documentation is for Web3Modal v2. You can find Web3Modal v3 docs here
openModalβ
Programmatically open the modal. Optionally, override default route to open.
Exampleβ
await web3modal.openModal()
Referenceβ
openModal: (options?: Options) => Promise<void>
// Options that can be passed to override default route
interface Options {
route?: 'Account' | 'ConnectWallet' | 'Help' | 'SelectNetwork'
}
closeModalβ
Programmatically close the modal.
Exampleβ
web3modal.closeModal()
Referenceβ
closeModal: () => void
subscribeModalβ
Subscribe or unsubscribe from modal's state.
Exampleβ
const unsubscribe = web3modal.subscribeModal(newState => console.log(newState))
unsubscribe()
Referenceβ
subscribeModal: (callback: (newState: Object) => void) => () => void
setDefaultChainβ
Sets the default chain before the user connects.
Exampleβ
web3modal.setDefaultChain(polygon)
Referenceβ
setDefaultChain: (chain: WagmiChain) => void
setThemeβ
Programmatically set or update theme options for themeVariables
and themeMode
.
Exampleβ
web3modal.setTheme({
themeMode: 'dark',
themeVariables: {
'--w3m-font-family': 'Roboto, sans-serif',
'--w3m-accent-color': '#F5841F'
// ...
}
})
Referenceβ
setTheme: (theme: Theme) => void
interface Theme {
themeMode: 'dark' | 'light'
themeVariables: Object
}
Wagmi Actionsβ
Other actions like getAccount
, getContract
and many more are available from wagmi.
Was this helpful?