The useVerifyNewAccount hook completes the account verification process after initiating authentication with email or phone number.

Import

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

Usage

function VerificationFlow() {
  const { verifyNewAccount, verifyNewAccountAsync, isPending, error } = useVerifyNewAccount();
  const [verificationCode, setVerificationCode] = useState("");
  const [identifier, setIdentifier] = useState(""); // email or phone

  const handleVerification = async () => {
    try {
      const result = await verifyNewAccountAsync({
        identifier,
        verificationCode
      });

      console.log("Account verified successfully");
    } catch (err) {
      console.error("Verification failed:", err);
    }
  };

  return (
    <div>
      <input
        type="text"
        value={identifier}
        onChange={(e) => setIdentifier(e.target.value)}
        placeholder="Email or phone used for signup"
      />
      
      <input
        type="text"
        value={verificationCode}
        onChange={(e) => setVerificationCode(e.target.value)}
        placeholder="Enter verification code"
        maxLength={6}
      />
      
      <button 
        onClick={handleVerification}
        disabled={isPending || !verificationCode || !identifier}
      >
        {isPending ? "Verifying..." : "Verify Account"}
      </button>
    </div>
  );
}