useChangePassword

Overview

The useChangePassword hook allows users to securely change their password.

Usage Example

import { useChangePassword } from "@replyke/react-js";
 
function ChangePasswordForm() {
  const changePassword = useChangePassword();
 
  const handleChangePassword = async () => {
    try {
      await changePassword({
        password: "currentPassword123",
        newPassword: "newSecurePassword456",
      });
 
      console.log("Password changed successfully");
    } catch (error) {
      console.error("Failed to change password:", error.message);
    }
  };
 
  return <button onClick={handleChangePassword}>Change Password</button>;
}

Parameters & Returns

Parameters

The hook returns a function that accepts an object with the following fields:

ParameterTypeRequiredDescription
passwordstringYesThe user’s current password.
newPasswordstringYesThe user’s new password.

Returns

The function does not return a value but ensures the password is updated on the server upon successful execution.