Overview
useRemoveAccount signs out and removes a specific account from the stored accounts map. It sends a sign-out request to the server to revoke the account’s refresh token family — and, once this device has a stored push identifier, to unbind that account’s push notifications in the same transaction — before removing any local state.
If the removed account is the currently active one, the session ends and no account is left active, even when other accounts remain stored. The app renders signed-out; choosing what happens next is yours.
Removing an account never activates a different one. Read
activeAccount from useAccounts and render your own next screen when it is null.Usage Example
Parameters
The hook returns aremoveAccount function that accepts:
string
required
The ID of the account to remove.
Returns
function
Async function that removes the specified account. It rejects without
doing anything when
userId is not in the accounts map — with an
AccountTransitionError
carrying accountNotFound: true, so a stale id is distinguishable from a
credential failure without matching on message text — or when no projectId
is available. Runtime errors during removal set error and reject the
returned promise. Removing a non-active account leaves the current session
untouched.boolean
true while the removal is in progress.string | null
Error message if the removal failed, or
null if no error occurred.
