update()

Updates user data, if there is a logged in user.

1const { user, error } = await supabase.auth.update({email: 'new@email.com'})

Parameters#

  • UserAttributesrequired
    object

    No description provided.

      Properties
    • dataoptional
      object

      A custom data object for user_metadata that a user can modify. Can be any JSON.

    • emailoptional
      string

      The user's email.

    • email_change_tokenoptional
      string

      An email change token.

    • passwordoptional
      string

      The user's password.

    • phoneoptional
      string

      The user's phone.

Notes#

User email: By Default, email updates sends a confirmation link to both the user's current and new email. To only send a confirmation link to the user's new email, disable Secure email change in your project's email auth provider settings.

User metadata: It's generally better to store user data in a table within your public schema (i.e., public.users). Use the update() method if you have data which rarely changes or is specific only to the logged in user.

Examples#

Update the email for an authenticated user#

Sends a "Confirm Email Change" email to the new email address.

1const { user, error } = await supabase.auth.update({email: 'new@email.com'})

Update the password for an authenticated user#

1const { user, error } = await supabase.auth.update({password: 'new password'})

Update the user's metadata#

1const { user, error } = await supabase.auth.update({
2  data: { hello: 'world' }
3})