#Disable user registrations (sign up)

4 messages · Page 1 of 1 (latest)

strange spindle
#

I am integrating Convex Auth with a Next.js app. How can I disable user registrations?

jolly mothBOT
#

Hi @strange spindle. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

To disable user registrations (sign up) when using Convex Auth with a Next.js app, the knowledge sources do not provide a direct, built-in configuration or flag to disable sign up entirely.

However, you can achieve this by customizing your authentication flow on the frontend. For example, if you are using the Password provider, you can simply remove or hide the "sign up" option from your UI and only allow the "sign in" flow to be submitted. In the example form from the Convex docs, the flow is controlled by a hidden input named flow:

<input name="flow" type="hidden" value={step} />

If you always set value="signIn" and do not provide a way for users to switch to "signUp", users will not be able to register new accounts via the UI. Here’s a simplified version:

<form
  onSubmit={(event) => {
    event.preventDefault();
    const formData = new FormData(event.currentTarget);
    formData.set("flow", "signIn");
    void signIn("password", formData);
  }}
>
  <input name="email" placeholder="Email" type="text" />
  <input name="password" placeholder="Password" type="password" />
  <button type="submit">Sign in</button>
</form>

This approach prevents new registrations from the client side, but does not technically disable the backend sign up logic. For stricter enforcement, you would need to customize the provider logic on the backend to reject sign up attempts, but the knowledge sources do not provide a code example for this.

If you are using a third-party provider (like Clerk or Auth0), you would need to configure sign up restrictions in their respective dashboards or APIs.

In summary:

  • Hide or remove the sign up UI and only allow sign in.
  • For stricter enforcement, consider customizing the backend provider logic, but the knowledge sources do not provide details on this.
#

If you need to fully block sign up attempts at the backend level, the knowledge sources do not contain enough information to provide a code example for that scenario.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: