"use client"; import { useAuthActions } from "@convex-dev/auth/react"; import { useRouter } from "next/navigation"; import { useState } from "react"; export default function SignIn() { const { signIn } = useAuthActions(); const [flow, setFlow] = useState<"signIn" | "signUp">("signIn"); const [error, setError] = useState(null); const router = useRouter(); return (

Log in to see the numbers

{ e.preventDefault(); const formData = new FormData(e.target as HTMLFormElement); formData.set("flow", flow); void signIn("password", formData) .catch((error) => { setError(error.message); }) .then(() => { router.push("/"); }); }} >
{flow === "signIn" ? "Don't have an account?" : "Already have an account?"} setFlow(flow === "signIn" ? "signUp" : "signIn")} > {flow === "signIn" ? "Sign up instead" : "Sign in instead"}
{error && (

Error signing in: {error}

)}
); }