useDisconnect() function
Hook for disconnecting the currently connected wallet
import { useDisconnect } from "@thirdweb-dev/react";
Example
The following will enable users to disconnect their wallet from the page.
import { useDisconnect } from "@thirdweb-dev/react";
const App = () => {
const disconnect = useDisconnect();
return <button onClick={disconnect}>Disconnect</button>;
};
Once users disconnect their wallet, the useAddress
, useChainId
, useAccount
, and useNetwork
hooks will no longer return values until a user connects their wallet again.
Signature:
export declare function useDisconnect(options?: {
reconnectAfterGnosis?: boolean;
}): () => Promise<void | {
data?: import("wagmi").ConnectorData<any> | undefined;
error?: Error | undefined;
}>;
Parameters
Parameter | Type | Description |
---|---|---|
options | { reconnectAfterGnosis?: boolean; } | (Optional) |
Returns:
() => Promise<void | { data?: import("wagmi").ConnectorData<any> | undefined; error?: Error | undefined; }>