Skip to main content
The useAddAuthMethod hook returns URL that allows a users to securely add a new auth method to their account. This hook is useful to allow basic login users migrate to a passkey, password or PIN auth method.

Import

import { useAddAuthMethod } from "@getpara/react-sdk";

Usage

function AddAuthMethod() {
  const { addAuthMethodAsync, isPending, error } = useAddAuthMethod({
    openPopup: false,
  });
  const [email, setEmail] = useState("");

  const handleAddAuthMethod = async () => {
    try {
      const url = await addAuthMethodAsync();

      console.log("Add auth method url:", url);

      // Open the URL in a new window
      window.open(url, "_blank", "width=500,height=700");
    } catch (err) {
      console.error("Add auth method failed:", err);
    }
  };

  return (
    <div>
      <button onClick={handleAddAuthMethod} disabled={isPending}>
        Add Auth Method
      </button>
    </div>
  );
}
I