A function (data) => Promise<null | string>. Call with sign-up payload. Returns null on success, or the error response text on failure.
import { useSignUp } from "naystack/auth/client";
function SignUpForm() {
const signUp = useSignUp();
const handleSubmit = async (data: { name: string; email: string; password: string }) => {
const error = await signUp(data);
if (error) {
setMessage(error); // e.g. "A user already exists"
} else {
router.replace("/dashboard");
}
};
}
Returns a sign-up function that POSTs to the auth endpoint with credentials. On success, the response's
accessTokenis stored and the token context updates automatically.The payload must include at least
emailandpassword. You can include any extra fields (e.g.name,designation) and they will be forwarded to thecreateUsercallback on the server.