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

Better Auth core includes account deletion. You do not need another plugin.

Enable the feature by setting user.deleteUser.enabled to true:

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

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

After you enable the feature, the client provides authClient.deleteUser(). You do not need a client plugin.

For an OAuth user without a password, provide sendDeleteAccountVerification. This callback lets the user confirm deletion by email.

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 @better-auth-ui/delete-user

This drops the following into your codebase:

  • src/lib/auth/auth-plugin.ts: local AuthPlugin typing widener
  • src/lib/auth/delete-user-plugin.ts: deleteUserPlugin() 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.

When credential confirmation is required, the password starts masked and includes a localized show/hide control.

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