naystack - v1.5.10
    Preparing search index...

    Function useSignUp

    • Returns a sign-up function that POSTs to the auth endpoint with credentials. On success, the response's accessToken is stored and the token context updates automatically.

      The payload must include at least email and password. You can include any extra fields (e.g. name, designation) and they will be forwarded to the createUser callback on the server.

      Returns (data: object) => Promise<string | null>

      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");
      }
      };
      }