BETTER-AUTH. UI
Plugins

Delete User

Add account deletion with confirmation dialog to your authentication flow.

The delete-user plugin renders the UI for Better Auth's built-in account deletion feature. Users can permanently delete their account with a confirmation dialog via the <DeleteAccount /> card, wrapped by <DangerZone /> in security settings.

Setup

Enable account deletion in Better Auth

Account deletion is built into Better Auth core — there's no separate plugin to install. Enable it by setting user.deleteUser.enabled to true:

lib/auth.ts
import { betterAuth } from "better-auth"

export const auth = betterAuth({
  // ...
  user: {
    deleteUser: { 
      enabled: true
    } 
  }
})

Once enabled, authClient.deleteUser() is available on the client — no client plugin is required. For OAuth users (who don't have a password), also provide sendDeleteAccountVerification so they can confirm deletion via email. See the Better Auth docs for the full options.

Install the UI plugin

Run the shadcn CLI to install the danger zone card and the deleteUserPlugin() factory into your project:

npx shadcn@latest add https://better-auth-ui.com/r/delete-user.json

This drops the following into your codebase:

  • src/lib/auth/auth-plugin.ts — local AuthPlugin typing widener
  • src/lib/auth/delete-user-plugin.tsdeleteUserPlugin() factory
  • src/components/auth/delete-user/danger-zone.tsx — the danger zone security card
  • src/components/auth/delete-user/delete-account.tsx — the delete account card with confirmation dialog

Register the plugin

Pass deleteUserPlugin() to <AuthProvider>:

components/providers.tsx
import { deleteUserPlugin } from "@/lib/auth/delete-user-plugin"
import { AuthProvider } from "@/components/auth/auth-provider"

<AuthProvider
  authClient={authClient}
  navigate={navigate}
  plugins={[deleteUserPlugin()]} 
>
  {children}
</AuthProvider>

Components

<DangerZone />

Danger zone

Delete account

Permanently remove your account and all associated data. This cannot be undone.

The <DangerZone /> card is automatically rendered in <SecuritySettings /> when the plugin is registered. It renders a danger zone heading and the <DeleteAccount /> card below it.

Usage

import { DangerZone } from "@/components/auth/delete-user/danger-zone"

<DangerZone />

Props

Prop

Type

<DeleteAccount />

The delete account card with confirmation dialog. Used inside <DangerZone /> by default; import it directly if you need a custom layout.

Usage

import { DeleteAccount } from "@/components/auth/delete-user/delete-account"

<DeleteAccount />

Props

Prop

Type

Options

Prop

Type

Localization

Prop

Type

Last updated on

On this page