Self-service password change
A signed-in user updates their password from account settings.
Better Auth · Module
Changes the authenticated user's password using the current password and a new password. It can optionally invalidate the user's other active sessions.
Call the client method with the user's current password and the replacement password. Set revokeOtherSessions to true when all other active sessions should be invalidated; the server-side API alternative requires session cookies.
authClient.changePassword({ newPassword, currentPassword, revokeOtherSessions? })| Name | Type | Description |
|---|---|---|
newPassword | string | The new password to set; required. |
currentPassword | string | The current user password; required. |
revokeOtherSessions | boolean | Invalidates all other active sessions when true. |
The documentation shows the returned data/error result for the client call; the server example returns the API result.
import { authClient } from "@/lib/auth-client";
const { data, error } = await authClient.changePassword({
newPassword: "new-password-123",
currentPassword: "current-password-123",
revokeOtherSessions: true,
});
if (error) throw error;
console.log(data);Changes the signed-in user's password and optionally invalidates the user's other active sessions.
A signed-in user updates their password from account settings.
A password update should sign out the account everywhere else.
A server action or API handler changes the password for an authenticated session.
Use authClient.changePassword with newPassword and currentPassword. The optional revokeOtherSessions flag invalidates every other active session when enabled.
Follow-up: How would you force this from server code? Use auth.api.changePassword with a body containing the password fields and pass session cookies in the request headers.
newPassword is the replacement password and currentPassword is the user's existing password; both are required. revokeOtherSessions is optional and controls whether other active sessions are invalidated.
Follow-up: What security context is needed by the server endpoint? An authenticated session represented by session cookies is required.
The server endpoint is POST /change-password and is called with auth.api.changePassword. Its request body contains the password values and optional session-revocation flag, while headers provide the session cookies.
Follow-up: When should session revocation be enabled? Enable it when changing the password should terminate the user's other active sessions.
auth.api.changePasswordsetPasswordrequestPasswordResetresetPasswordrevokeOtherSessions