BETTER-AUTH. UI
Mutations

useUpdateUser

Update the authenticated user's profile fields.

On success, the variables are optimistically merged into the cached session's user object, then the session is refetched to reconcile with the server.

Usage

import { useAuth, useUpdateUser } from "@better-auth-ui/react"

const { authClient } = useAuth()
const { mutate: updateUser, isPending } = useUpdateUser(authClient)

updateUser({ name: "Alice", image: "https://.../avatar.png" })

Options factory

import { updateUserOptions } from "@better-auth-ui/react"
import { useMutation } from "@tanstack/react-query"

const { mutate } = useMutation(updateUserOptions(authClient))

Note: using the raw factory skips the optimistic session merge — prefer useUpdateUser 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

On this page