updateUser()

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

1final UserResponse res = await supabase.auth.updateUser(
2  UserAttributes(
3    email: 'example@email.com',
4  ),
5);
6final User? updatedUser = res.user;

Notes#

  • In order to use the updateUser() method, the user needs to be signed in first.
  • 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.

Examples#

Update the email for an authenticated user#

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

1final UserResponse res = await supabase.auth.updateUser(
2  UserAttributes(
3    email: 'example@email.com',
4  ),
5);
6final User? updatedUser = res.user;

Update the password for an authenticated user#

1final UserResponse res = await supabase.auth.updateUser(
2  UserAttributes(
3    password: 'new password',
4  ),
5);
6final User? updatedUser = res.user;

Update the user's metadata#

1final UserResponse res = await supabase.auth.updateUser(
2  UserAttributes(
3    data: { 'hello': 'world' },
4  ),
5);
6final User? updatedUser = res.user;