Skip to main content

Reset Password (Email)

Sends a reset request to an email address.

final res = await supabase.auth.api.resetPasswordForEmail('user@example.com');

final error = res.error;

Notes

Sends a reset request to an email address.

When the user clicks the reset link in the email they will be forwarded to:

<SITE_URL>#access_token=x&refresh_token=y&expires_in=z&token_type=bearer&type=recovery

Your app must detect type=recovery in the fragment and display a password reset form to the user.

You should then use the access_token in the url and new password to update the user as follows:

final res = await supabase.auth.api.updateUser(
accessToken,
UserAttributes(password: 'NEW_PASSWORD'),
);

Examples

Reset password

final res = await supabase.auth.api.resetPasswordForEmail('user@example.com');

final error = res.error;

Reset password for Flutter

You can pass redirectTo to open the app via deeplink when user opens the password reset email.

final res = await supabase.auth.api.resetPasswordForEmail(
'user@example.com',
options: AuthOptions(redirectTo: kIsWeb
? null
: 'io.supabase.flutter://reset-callback/'),
);

final error = res.error;