You’re viewing the 2.0 (LTS) docs. View the current 3.0 version of this page.
useSignUpOrLogIn hook initiates the authentication flow for new or existing users, handling both sign-up and login scenarios automatically.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Hook for initiating the authentication flow
useSignUpOrLogIn hook initiates the authentication flow for new or existing users, handling both sign-up and login scenarios automatically.
import { useSignUpOrLogIn } from "@getpara/react-sdk";
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>
);
}