Function: useAccounts()
function useAccounts(options?: UseAccountsOptions): UseAccountsReturn;
Defined in: useAccounts.ts:63
Account-focused hook that provides account state and an optional callback when the selected account changes.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | UseAccountsOptions | Optional configuration including an account selection callback |
Returns
Account state from the current wallet session
Remarks
Use this hook when you only need account state without connection actions.
Unlike useWallet, this hook does not expose connect(), disconnect(),
or mountInline() — it is read-only with an optional onAccountSelect callback.
The onAccountSelect callback fires whenever the selected account changes,
including on initial connection when the first account is auto-selected.
Example
function AccountList() {
const { accounts, selectedAccount } = useAccounts({
onAccountSelect: (account) => console.log('Selected:', account.address),
});
return (
<ul>
{accounts.map((a) => (
<li key={a.address}>{a.address === selectedAccount?.address ? '* ' : ''}{a.address}</li>
))}
</ul>
);
}
See
- useWallet — for full wallet operations (connect, disconnect, sign)
- KeaProvider — required provider