useConnect
Hook for connecting any supported wallet config to your app.
import { useConnect } from "@thirdweb-dev/react";
const connect = useConnect();
The wallet also needs to be added in ThirdwebProvider's supportedWallets if you want the wallet to auto-connect on next page load.
Usage
import { useConnect, metamaskWallet } from "@thirdweb-dev/react";
const metamaskConfig = metamaskWallet();
function App() {
const connect = useConnect();
return (
<button
onClick={async () => {
const wallet = await connect(metamaskConfig, connectOptions);
console.log("connected to ", wallet);
}}
>
Connect to MetaMask
</button>
);
}