The useSignUpOrLogIn hook initiates the authentication flow for new or existing users, handling both sign-up and login scenarios automatically.

Import

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

Usage

function AuthenticationFlow() {
  const { signUpOrLogIn, signUpOrLogInAsync, isPending, error } = useSignUpOrLogIn();
  const [email, setEmail] = useState("");

  const handleAuth = async () => {
    try {
      const result = await signUpOrLogInAsync({
        email,
        isGuestMode: false
      });

      console.log("Authentication initiated:", result);
    } catch (err) {
      console.error("Authentication failed:", err);
    }
  };

  return (
    <div>
      <input
        type="email"
        value={email}
        onChange={(e) => setEmail(e.target.value)}
        placeholder="Enter your email"
      />
      
      <button 
        onClick={handleAuth}
        disabled={isPending || !email}
      >
        {isPending ? "Processing..." : "Sign Up / Log In"}
      </button>
    </div>
  );
}