Send the recovery challenge
passwordReset sends a recovery email to the user. redirectTo controls where the recovery link returns the user.
const result = await client.auth.passwordReset( 'user@example.com', { redirectTo: 'https://app.example.com/reset-password' }) if (result.error) { throw result.error}Confirm the new password
Pass the recovery code with the email address and new password. A successful confirmation updates the password, returns the user and session, and stores the authenticated session.
const result = await client.auth.passwordResetConfirm({ email: 'user@example.com', token: recoveryCode, new_password: 'password123' }) if (result.error) { throw result.error} console.log(result.data.user)console.log(result.data.session)Change a password while signed in
updateUserPassword changes the password for the user in the current authenticated session and returns the updated user object.
const result = await client.auth.updateUserPassword({ current_password: 'current-password', new_password: 'password123' }) if (result.error) { throw result.error} console.log(result.data.user)