Docs

useConnect

A hook to set a wallet as active wallet

Example

import { useConnect } from "thirdweb/react";
import { metamaskWallet } from "thirdweb/wallets";
function Example() {
const { connect, isConnecting, error } = useConnect();
return (
<button
onClick={() =>
connect(async () => {
// instantiate wallet
const wallet = metamaskWallet();
// connect wallet
await wallet.connect();
// return the wallet
return wallet;
})
}
>
Connect
</button>
);
}

Returns

A function that lets you connect a wallet.