Skip to content

useConnect

Connection flow

A dApp must connect with the wallet before communication between dApps and wallet can begin. A dApp can only have one WalletConnect session at a time.

Usage

import { useConnect } from '@puzzlehq/sdk';
export const ConnectPage = () => {
const { connect, data, error, loading } = useConnect();
return (
<div>
<button
onClick={ () => connect() }
disabled={ loading }
>
connect to puzzle
</button>
{ data && <p>you did it!</p> }
{ error && <p>error connecting: {error}</p> }
</div>
)
}

Return Value

{
connect: () => void, // do not pass in parameters
data?: SessionTypes.Struct, // WalletConnect session type
error?: string,
loading: boolean,
}