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:
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.
Register the UI plugin
Pass deleteUserPlugin() to <AuthProvider>:
import { AuthProvider } from "@better-auth-ui/heroui"
import { deleteUserPlugin } from "@better-auth-ui/heroui/plugins/delete-user"
<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 "@better-auth-ui/heroui/plugins/delete-user"
<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 "@better-auth-ui/heroui/plugins/delete-user"
<DeleteAccount />Props
Prop
Type
Options
Prop
Type
Localization
Prop
Type
Last updated on