usePayer

function usePayer(client): TransactionSigner | undefined;

Reads client.payer and re-renders whenever it changes, returning undefined while no payer is available.

The payer is the TransactionSigner a client uses to sign and pay for transactions by default.

When the client advertises ClientWithSubscribeToPayer, this hook subscribes via client.subscribeToPayer so the returned value always reflects the latest payer. For a client whose payer is fixed for its lifetime, the hook falls back to a no-op subscription and simply reads the value once.

Parameters

ParameterTypeDescription
clientClientWithPayer & Partial<ClientWithSubscribeToPayer>A client with a payer plugin installed. If it also advertises subscribeToPayer, the hook tracks changes reactively.

Returns

TransactionSigner | undefined

The current client.payer signer, or undefined if no payer is currently available.

Example

const payer = usePayer(client);
return <span>{payer ? `Paying with ${payer.address}` : 'No payer'}</span>;

See

useIdentity

On this page