Authentication
Sign in a user with one of the following methods:
  • Email and Password
  • Passwordless Email (Magic Link)
  • Passwordless SMS
  • OAuth Provider
If the user does not exist, the user is created. Only exception is when using Email and Password. To sign in a user with Email and password a user first must sign up.
nhost.auth.signIn({
  email: 'username@gmail.com',
  password: 'my-secret-password',
});

An email will be sent to the user's email with a link. When the user clicks on the link the user will be automatically redirected and signed-in to your app.
nhost.auth.signIn({
  email: 'username@gmail.com',
});

Start the sign-in process for a user using SMS. This will send a One-time Password (OTP) to the user:
nhost.auth.signIn({
  phoneNumber: '+46123456789',
});

To verify the phone number and to sign in the user, combine the phone number and the OTP for the user:
nhost.auth.signIn({
  phoneNumber: '+46123456789',
  otp: '<otp-from-sms>',
});

The following providers are available:
  • google
  • github
  • facebook
  • spotify
nhost.auth.signIn({
  provider: 'google',
});


Sign up a new user using email and password.
nhost.auth.signUp({
  email: 'username@gmail.com',
  password: 'my-secret-password',
  options: {
    displayName: 'John Doe',
  },
});

Sign Out the current user.
Get information about the current user.
Change email of the current user. For the new email to be in effect, the user must verify the new email address by clicking on the link in the email that is sent out after executing this method.
nhost.auth.changeEmail({ newEmail });

Change password of the current user. The old password is not needed when changing the password.
nhost.auth.changePassword({ newPassword });

Reset password for a user. This will send an email to the user with a link to reset the password.
nhost.auth.resetPassword({ email });