Change profile image
Let a signed-in user replace their avatar URL from an account-settings screen.
Better Auth · Module
Better Auth's client exposes updateUser for changing user information. Supply the desired profile fields in an object, such as image and name.
Call the client’s updateUser method with an object containing the profile fields to change. The documented example updates both image and name for the current user.
await authClient.updateUser({ image, name })| Name | Type | Description |
|---|---|---|
data | object | Object containing the user information to update; the page's example includes image and name. |
import { authClient } from "@/lib/auth-client"
await authClient.updateUser({
image: "https://example.com/image.jpg",
name: "John Doe",
})Updates the signed-in user's profile image and display name through the configured Better Auth client.
Let a signed-in user replace their avatar URL from an account-settings screen.
Let a signed-in user edit the name shown throughout the application.
Submit several profile edits together after a settings form is saved.
Call authClient.updateUser with an object containing the user fields that should change. The documented example passes image and name.
Follow-up: How would you update only one field? Pass an object containing only that field, such as { name: "New Name" }, assuming the client supports the field.
The method is exposed by the Better Auth client, so the client must already be configured and imported before calling it. The page demonstrates importing authClient from a local auth-client module.
Follow-up: Where should client configuration live? In the application's shared Better Auth client module, which can then be imported wherever profile updates are needed.
The documented update payload includes image and name properties. The image value is a URL string, while name is the user's display-name string.
Follow-up: What should be validated before sending an image URL? Validate the URL and any application-specific profile rules before invoking the client method.
authClientcreateAuthClientusers and accounts