> ## 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.

# Account Deletion

<Card title="Recommended: JavaScript SDK with React Hooks" icon="react" color="#4779FE">
  For new React apps, we recommend the JavaScript SDK with React Hooks (`@dynamic-labs-sdk/react-hooks`) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the [React quickstart (JavaScript SDK)](/javascript/reference/react-quickstart) to get started.
</Card>

<Note>This guide is currently React only.</Note>

## Introduction

This guide shows you how to implement account deletion functionality without using Dynamic's UI components. When a user deletes their account, all associated data will be permanently removed, including their wallets, embedded wallets, verified credentials, etc.

<Warning>
  Account deletion is permanent and cannot be undone. All associated data will
  be irrecoverably deleted.
</Warning>

## Using our UI

The widget includes account deletion in the Account & Security section. Users can self-serve deletion from there.

<Frame>
  <img src="https://mintcdn.com/dynamic-docs/S0I4gBjjMnJYbuz8/images/widget/widget-account-deletion.png?fit=max&auto=format&n=S0I4gBjjMnJYbuz8&q=85&s=940d10bdb37dcf5bdbb2a9cce27211c0" alt="Account Deletion" width="866" height="1180" data-path="images/widget/widget-account-deletion.png" />
</Frame>

<Warning>
  Account deletion is permanent and cannot be undone. All associated data will be irrecoverably deleted.
</Warning>

## Using your UI

Use the `useDeleteUserAccount` hook to handle account deletion with loading states and error handling.

```tsx React theme={"system"}
import { FC } from 'react';
import { useDeleteUserAccount } from '@dynamic-labs/sdk-react-core';

const DeleteAccount: FC = () => {
  const { deleteUser, error, isLoading } = useDeleteUserAccount();

  const handleDeleteAccount = async () => {
    try {
      await deleteUser();
    } catch (err) {
      console.error('Failed to delete account:', err);
    }
  };

  return (
    <div>
      <button onClick={handleDeleteAccount} disabled={isLoading}>
        {isLoading ? 'Deleting...' : 'Delete Account'}
      </button>

      {error && <p className="error">Error: {error.message}</p>}
    </div>
  );
};
```

## Best Practices

* Always confirm deletion: include a confirmation step before proceeding.
* Clearly explain what data will be deleted and that the action is permanent.

## Hook Types and Functions

The `useDeleteUserAccount` hook provides:

* `deleteUser`: Function to initiate account deletion
* `isLoading`: Boolean indicating if deletion is in progress
* `error`: Error object if deletion fails
