Next.js Discord

Discord Forum

i get this error "Error: async/await is not yet supported in Client Components, only Server Componen

Unanswered
Blood cockle posted this in #help-forum
Open in Discord
Blood cockleOP
import { useSignUp } from "@clerk/nextjs";
export default function Page() {
  // const [error, setError] = useState<string>("");
  const { isLoaded, signUp, setActive } = useSignUp();
  function handleSubmit(e: any) {
    e.preventDefault();
    const email = e.target.email.value;
    const password = e.target.password.value;

    if (!isLoaded) {
      return null;
    }

    signUp
      .create({
        emailAddress: email,
        password: password,
      })
      .then((result) => {
        if (result.status === "complete") {
          console.log(result);
          setActive({ session: result.createdSessionId });
        } else {
          console.log(result);
        }
      })
      .catch((err) => console.error("error", err.errors[0].longMessage));
  }

  return (
//jsx here )

8 Replies

European sprat
is this the full code? if it is, you can't use hooks in a server component
Blood cockleOP
no this is a client component
i used "use client " at the top
@European sprat
it happens with useSignUp hook
while using use client at the top
European sprat
you shouldn't use client components for pages. make another component a client component and import that into the page
Blood cockleOP
ok i will try it