Skip to main content

useConnect

Hook for viewing the connection status and what connectors are available to be used as defined in the ThirdwebProviders walletConnectors prop.

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

Usage

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

function App() {
const [{ data }, connect] = useConnect();
}

Return Value

The data property contains an object with the following properties:

{
connected: boolean; // Whether the user is connected to this site with their wallet
connector: Connector<any, any> | undefined; // The connector that the user is connected with (or undefined)
connectors: Connector<any, any>[]; // All the connectors that are available to be used
}

The connect property is a function that takes a connector as an argument and connects the user to your dapp using that connector.

(connector: Connector<any, any>) =>
Promise<{
data?: ConnectorData<any> | undefined;
error?: Error | undefined;
}>;