import { useScuteAuthFlow } from "@scute/auth-ui-react";
function Auth() {
const auth = useScuteAuthFlow();
if (auth.isAuthenticated) return <App />;
if (auth.view === "login") {
return (
<form onSubmit={(e) => { e.preventDefault(); auth.submitIdentifier(); }}>
<input
value={auth.identifier}
onChange={(e) => auth.setIdentifier(e.target.value)}
placeholder="you@example.com"
/>
<button>{auth.submitting ? "..." : "Continue"}</button>
</form>
);
}
if (auth.view === "magic_pending") {
return <p>Check your email: {auth.identifier}</p>;
}
if (auth.view === "webauthn_register") {
return (
<div>
<p>Register a passkey?</p>
<button onClick={auth.registerPasskey}>Register</button>
<button onClick={auth.skipPasskey}>Skip</button>
</div>
);
}
return <p>Loading...</p>;
}