"use client"; import { Suspense, useState } from "react"; import { useRouter, useSearchParams } from "next/navigation"; import Link from "next/link"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; function SignUpInner() { const router = useRouter(); const sp = useSearchParams(); const [username, setUsername] = useState(""); const [email, setEmail] = useState(""); // optional const [password, setPassword] = useState(""); const [submitting, setSubmitting] = useState(false); const [err, setErr] = useState(null); const next = sp.get("next") || "/my/rigs"; async function onSubmit(e: React.FormEvent) { e.preventDefault(); setErr(null); setSubmitting(true); try { const res = await fetch("/api/auth/register", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ username, email: email || undefined, password, }), }); const data = await res.json().catch(() => ({})); if (!res.ok) throw new Error(data?.error || "Registration failed"); router.replace(next); } catch (e: any) { setErr(e?.message || "Registration failed"); } finally { setSubmitting(false); } } return (

Create account

Pick a username and password. Email is optional (recommended for password reset).

{err && (
{err}
)}
setUsername(e.target.value)} required />
setEmail(e.target.value)} />

Without an email, we can’t reset your password if you lose it.

setPassword(e.target.value)} required />

Already have an account?{" "} Sign in

); } export default function SignUpPage() { return (
Loading…
} >
); }