> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete User Account

> Permanently delete the current user's account.

`deleteUser` performs a hard delete of the authenticated user. All associated data — wallets, embedded wallets, verified credentials, metadata — is permanently removed. Once the API call succeeds, the SDK automatically logs the user out and clears all client-side authentication state.

> [!WARNING]
>
> Account deletion is permanent and cannot be undone. All associated data will be irrecoverably deleted.

## Usage

> [tab] JavaScript
>
> ```javascript theme={"system"}
> import { deleteUser } from '@dynamic-labs-sdk/client';
>
> const handleDelete = async () => {
>   try {
>     await deleteUser();
>     // Auto-logout has already happened — redirect or update UI.
>   } catch (error) {
>     console.error('Failed to delete account:', error);
>   }
> };
> ```

> [tab] React
>
> ```tsx theme={"system"}
> import { useDeleteUser } from '@dynamic-labs-sdk/react-hooks';
>
> function DeleteAccountButton() {
>   const { mutate: deleteUser, isPending, error } = useDeleteUser();
>
>   return (
>     <div>
>       <button onClick={() => deleteUser()} disabled={isPending}>
>         {isPending ? 'Deleting…' : 'Delete account'}
>       </button>
>       {error instanceof Error && <p>Error: {error.message}</p>}
>     </div>
>   );
> }
> ```

## Behavior

* Requires an authenticated user — call only when `dynamicClient.user` is set (see [Check if signed in](https://docs.dynamic.xyz/docs/javascript/user-session-management.md#check-if-signed-in)).
* The API call is gated by MFA: if the user has MFA enabled and the action requires step-up, you'll see an MFA challenge surface. Handle it with [`isMfaRequiredForAction`](https://docs.dynamic.xyz/docs/javascript/authentication-methods/mfa/action-based) before invoking `deleteUser`.
* On success, the client emits `logout` (with `reason: 'user-deleted'`) and `userChanged` (`{ user: null }`). Subscribe via [`onEvent`](https://docs.dynamic.xyz/docs/javascript/reference/client/on-event) or use the React hook `useUser` to react to the change.

## Best practices

* **Confirm first.** Always require an explicit confirmation step (a typed-in account name or a "Delete" word match works well).
* **Explain scope.** Tell the user what is removed — wallets, balances, credentials, metadata — and that the action is irreversible.
* **Clear local state.** If you cache user data outside the SDK (Redux, query caches, IndexedDB), clear it on success.

## Related functions

* [Logout](https://docs.dynamic.xyz/docs/javascript/reference/client/on-event.md) — log the user out without deleting their data
* [User & Session Management](https://docs.dynamic.xyz/docs/javascript/user-session-management.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.