useConnectWallet
The useConnectWallet
hook is a mutation hook for establishing a connection to a specific wallet.
Live Editor
function UseConnectWalletExample() { const wallets = useWallets(); const { mutate: connect } = useConnectWallet(); return ( <div style={{ padding: 20 }}> <ul> {wallets.map((wallet) => ( <li key={wallet.name}> <button onClick={() => { connect( { wallet }, { onSuccess: () => console.log('connected'), }, ); }} > Connect to {wallet.name} </button> </li> ))} </ul> </div> ); }
Result
Loading...
Connect arguments
-
args
- Arguments passed to theconnect
function of the wallet.wallet
- The wallet to connect to.accountAddress
- (optional) The address in the wallet to connect to.
-
options
- Options passed theuseMutation
hook from @tanstack/react-query.