useActiveWallet

A hook that returns the active wallet

Example

Basic usage

import { useActiveWallet } from "thirdweb/react";
const wallet = useActiveWallet();

Listen to account change event

const wallet = useActiveWallet();
wallet?.subscribe("accountChanged", (account) => {
console.log(account);
});

Listen to multiple accounts changed event

const wallet = useActiveWallet();
wallet?.subscribe("accountsChanged", (addresses) => {
console.log(addresses);
});

Listen to network change event

const wallet = useActiveWallet();
wallet?.subscribe("chainChanged", (chain) => {
console.log(chain);
});
function useActiveWallet(): undefined | Wallet;

Returns

let returnType: undefined | Wallet;

The active Wallet or undefined if no active wallet is set.