Mutations
useSignOut
Sign out the current session and clear the auth cache.
Removes every ["auth", ...] query on success, clearing the session, linked accounts, sessions, device sessions, and passkeys in one go.
Usage
import { useAuth, useSignOut } from "@better-auth-ui/react"
const { authClient } = useAuth()
const { mutate: signOut } = useSignOut(authClient, {
onSuccess: () => navigate("/")
})
signOut()Options factory
import { signOutOptions } from "@better-auth-ui/react"
import { useMutation } from "@tanstack/react-query"
const { mutate } = useMutation(signOutOptions(authClient))Note: using the raw factory skips the cache cleanup — prefer useSignOut unless you only need a stable options object (for example to match on mutationKey inside a global MutationCache observer).
Params
Prop
Type
Last updated on