Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Better Auth · Module

resetPassword

resetPassword completes Better Auth’s email/password recovery flow. After the user receives a token-bearing reset link, call it with the token and the replacement password.

How it works

Email/password reset requires a configured sendResetPassword callback to deliver a token-bearing URL. The client first requests the reset link; after the user reaches the reset page, resetPassword receives the new password and token, while token validity is controlled by resetPasswordTokenExpiresIn.

Syntax

await authClient.resetPassword({ newPassword, token });

Parameters

NameTypeDescription
newPasswordstringThe new password to assign to the user.
tokenstringThe verification token from the reset link.

Returns

The client methods return an object containing data and error, as shown in the documentation examples.

Key points

  • Enable the email/password reset flow by supplying sendResetPassword in the emailAndPassword configuration.
  • The callback receives a data object containing the user, reset URL, and verification token.
  • Use requestPasswordReset to initiate delivery of the reset link from the client.
  • Your application must provide the destination reset-password page that handles the link.
  • Call resetPassword from the reset page to apply the new credential.
  • The reset operation accepts an object whose documented password field is newPassword; the token is also required by the client example.

Common mistakes

  • The reset-email callback runs only when the requested account exists; your application should not assume it runs for every address.
  • Sessions are not all revoked by default; enable revokeSessionsOnPasswordReset when a password change should invalidate existing sessions.

Example: Request and complete an email password reset

import { betterAuth } from "better-auth";
import { authClient } from "./auth-client";

export const auth = betterAuth({
  emailAndPassword: {
    enabled: true,
    sendResetPassword: async ({ user, url }) => {
      console.log(`Send reset link to ${user.email}: ${url}`);
    },
  },
});

const { data, error } = await authClient.requestPasswordReset({
  email: "user@example.com",
  redirectTo: "https://app.example.com/reset-password",
});

if (error) throw error;

const token = new URL(data?.url ?? "").searchParams.get("token");
if (!token) throw new Error("Missing reset token");

const result = await authClient.resetPassword({
  newPassword: "new-secure-password",
  token,
});
if (result.error) throw result.error;

Configure the reset-email callback, request a reset link, then pass the link token and new password to the reset method.

When to use it

Forgotten-password recovery

A user has forgotten an email/password account credential and needs a secure replacement flow.

Reset-page submission

An application provides a reset page reached through the emailed token URL.

Credential-change session revocation

A security-sensitive application must invalidate current sessions after a successful password change.

Interview questions

QWhat is the documented email/password reset flow?

Configure emailAndPassword.sendResetPassword to deliver the URL containing the reset token. Then call requestPasswordReset and, from the reset page, call resetPassword with newPassword and token.

Follow-up: How can existing sessions be invalidated after the change? Enable revokeSessionsOnPasswordReset; the documentation says this revokes all user sessions during reset.

QWhat does sendResetPassword receive?

The callback receives user, url, and token. The URL is intended for the user, while the token is the verification value needed to complete the reset.

Follow-up: What controls token lifetime? resetPasswordTokenExpiresIn sets the validity duration in seconds, with a documented default of 3600.

QWhy are requestPasswordReset and resetPassword separate operations?

The password reset endpoint is separate from the request step: requestPasswordReset sends the link, and resetPassword changes the password using the token and new password.

Follow-up: What callback can observe completion? onPasswordReset runs after the new password is saved and, when configured, after sessions are revoked.

  • requestPasswordReset
  • sendResetPassword
  • resetPasswordTokenExpiresIn
  • revokeSessionsOnPasswordReset
  • onPasswordReset

Source: Email & Password. Checked 2026-10-15.