Skip to content

useDisconnect

Usage

useConnect must be called and WalletConnect session must be initiated before you can deploy a program.

Disconnects a dApp from the Puzzle Wallet. An active WalletConnect session must be in place for disconnect to work.

import { useConnect, useDisconnect } from '@puzzlehq/sdk';
const { account } = useAccount();
const { disconnect, error, loading } = useDisconnect();
const isConnected = !!account;
return (
<div>
<button
onClick={() => {
if (isConnected) disconnect();
}}
disabled={loading}
>
disconnect
</button>
{error && <p>error disconnecting your dApp: {error}</p>}
{loading && <p>disconnecting your dApp...</p>}
</div>
)

Return Value

{
disconnect: () => {void},
error?: string, // WalletConnect error or Puzzle wallet error,
loading: boolean,
};