Mutations
useDeleteUser
Delete the authenticated user's account.
Depending on your Better Auth server config, this either deletes the account immediately or sends a confirmation email.
Usage
import { authClient } from "@/lib/auth-client"
import { useDeleteUser } from "@better-auth-ui/react"
const { mutate: deleteUser } = useDeleteUser(authClient)
deleteUser({ password: "hunter2", callbackURL: "/" })After an immediate deletion, use useSignOut to clear the cache. Alternatively, call queryClient.removeQueries({ queryKey: ["auth"] }).
Options factory
import { deleteUserOptions } from "@better-auth-ui/core"
import { useMutation } from "@tanstack/react-query"
const { mutate } = useMutation(deleteUserOptions(authClient))Params
Prop
Type
Last updated on