useIdentity

function useIdentity(client): TransactionSigner | undefined;

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

The identity is the TransactionSigner representing the wallet whose on-chain assets the application is acting upon.

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

Parameters

ParameterTypeDescription
clientClientWithIdentity & Partial<ClientWithSubscribeToIdentity>A client with an identity plugin installed. If it also advertises subscribeToIdentity, the hook tracks changes reactively.

Returns

TransactionSigner | undefined

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

Example

const identity = useIdentity(client);
return <span>{identity ? `Signed in as ${identity.address}` : 'Signed out'}</span>;

See

usePayer

On this page