signUp()

Creates a new user.

1const { data, error } = await supabase.auth.signUp({
2  email: 'example@email.com',
3  password: 'example-password',
4})

Parameters#

  • SignUpWithPasswordCredentialsrequired
    reflection
    |
    reflection

    No description provided.

      Properties
    • object
      required
      object

      No description provided.

        Properties
      • phonerequired
        string

        The user's phone number.

      • passwordrequired
        string

        The user's password.

      • optionsoptional
        object

        No description provided.

          Properties
        • captchaTokenoptional
          string

          Verification token received when the user completes the captcha on the site.

        • dataoptional
          object

          A custom data object to store the user's metadata. This maps to the auth.users.user_metadata column.

          The data should be a JSON object that includes user-specific info, such as their first and last name.

    • object
      required
      object

      No description provided.

        Properties
      • passwordrequired
        string

        The user's password.

      • emailrequired
        string

        The user's email address.

      • optionsoptional
        object

        No description provided.

          Properties
        • captchaTokenoptional
          string

          Verification token received when the user completes the captcha on the site.

        • dataoptional
          object

          A custom data object to store the user's metadata. This maps to the auth.users.user_metadata column.

          The data should be a JSON object that includes user-specific info, such as their first and last name.

        • emailRedirectTooptional
          string

          The redirect url embedded in the email link

Notes#

  • By default, the user needs to verify their email address before logging in. To turn this off, disable Confirm email in your project.
  • Confirm email determines if users need to confirm their email address after signing up.
    • If Confirm email is enabled, a user is returned but session is null.
    • If Confirm email is disabled, both a user and a session are returned.
  • When the user confirms their email address, they are redirected to the SITE_URL by default. You can modify your SITE_URL or add additional redirect URLs in your project.
  • If signUp() is called for an existing confirmed user:
    • If Confirm email is enabled in your project, an obfuscated/fake user object is returned.
    • If Confirm email is disabled, the error message, User already registered is returned.
  • To fetch the currently logged-in user, refer to getUser().

Examples#

Sign up.#

1const { data, error } = await supabase.auth.signUp({
2  email: 'example@email.com',
3  password: 'example-password',
4})

Sign up with additional user metadata.#

1const { data, error } = await supabase.auth.signUp(
2  {
3    email: 'example@email.com',
4    password: 'example-password',
5    options: {
6      data: {
7        first_name: 'John',
8        age: 27,
9      }
10    }
11  }
12)