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 { useAuth, useDeleteUser } from "@better-auth-ui/react"
const { authClient } = useAuth()
const { mutate: deleteUser } = useDeleteUser(authClient)
deleteUser({ password: "hunter2", callbackURL: "/" })After a successful immediate deletion you'll typically want to pair this with useSignOut (or call queryClient.removeQueries({ queryKey: ["auth"] }) yourself) to clear the cache.
Options factory
import { deleteUserOptions } from "@better-auth-ui/react"
import { useMutation } from "@tanstack/react-query"
const { mutate } = useMutation(deleteUserOptions(authClient))Params
Prop
Type
Last updated on