Skip to main content

useMetamask

Hook that requests users to connect their MetaMask Wallet to your dApp.

import { useMetamask } from "@thirdweb-dev/react";

Usage

Call the function returned by the hook to prompt the user to connect their MetaMask wallet to your dApp.

You can then use the useAddress hook to get the user's address.

import { useMetamask } from "@thirdweb-dev/react";

function App() {
const connectWithMetamask = useMetamask();

return <button onClick={connectWithMetamask}>Connect Metamask</button>;
}

Once connected, use the useAddress hook to get the address of the connected wallet.