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

# Confirm account deletion

> Verify the emailed code and permanently delete the authenticated user's account

## Overview

`useConfirmAccountDeletion` returns a function that submits the confirmation code from [`useRequestAccountDeletion`](/hooks/auth/use-request-account-deletion) and **permanently deletes** the authenticated user's account. On success, the local session is torn down just like a sign-out: the deleted account is removed from the multi-account map, and the SDK switches to a remaining signed-in account if there is one (otherwise the user is fully logged out).

<Warning>
  Deletion is **immediate and irreversible**. There is no grace period and no
  recovery once this resolves.
</Warning>

## Usage Example

<CodeGroup>
  ```tsx React theme={null}
  import { useConfirmAccountDeletion } from "@sublay/react-js";
  import { useState } from "react";

  function ConfirmDeletionForm() {
    const confirmAccountDeletion = useConfirmAccountDeletion();
    const [code, setCode] = useState("");
    const [error, setError] = useState("");

    const handleSubmit = async (e: React.FormEvent) => {
      e.preventDefault();
      setError("");
      try {
        await confirmAccountDeletion({ code });
        // Account is gone and the session has been cleared.
      } catch (err: any) {
        setError(err.message ?? "Deletion failed.");
      }
    };

    return (
      <form onSubmit={handleSubmit}>
        {error && <p>{error}</p>}
        <input
          value={code}
          onChange={(e) => setCode(e.target.value)}
          placeholder="Enter the code from your email"
        />
        <button type="submit">Permanently delete my account</button>
      </form>
    );
  }
  ```

  ```tsx React Native theme={null}
  import { useConfirmAccountDeletion } from "@sublay/react-native";

  function ConfirmDeletionScreen({ code }: { code: string }) {
    const confirmAccountDeletion = useConfirmAccountDeletion();

    return (
      <Button
        title="Permanently delete my account"
        onPress={() => confirmAccountDeletion({ code })}
      />
    );
  }
  ```
</CodeGroup>

## Parameters

The returned function accepts:

<ParamField path="code" type="string" required>
  The one-time confirmation code the user received by email. Must match the most recently issued code exactly.
</ParamField>

## Returns

The hook returns an async function that resolves to `void` on success. It throws if the code is invalid or expired, or if the deletion fails.

<Note>
  You don't need to call `signOut` afterward — the hook clears the local session
  for you and switches to a remaining account if the user had several signed in.
</Note>

## See Also

* [`useRequestAccountDeletion`](/hooks/auth/use-request-account-deletion)
* [Confirm Account Deletion API reference](/api-reference/auth/confirm-account-deletion)
