auth.signIn()

Log in an existing user, or login via a third-party provider.

const { user, error } = await supabase.auth.signIn({
email: 'example@email.com',
password: 'example-password',
})

Parameters

  • credentialsrequiredobject

    The user login details.

      Properties
    • provideroptionalProvider

      One of the providers supported by GoTrue.

    • passwordoptional|

      The user's password.

    • emailoptional|

      The user's email address.

Notes

  • A user can sign up either via email or OAuth.
  • If you provide email without a password, the user will be sent a magic link.
  • Specifying a provider will open the browser to the relevant login page.

Examples

Sign in with email.

const { user, error } = await supabase.auth.signIn({
email: 'example@email.com',
password: 'example-password',
})

Sign in with magic link.

If no password is provided, the user will be sent a "magic link" to their email address, which they can click to open your application with a valid session. By default, a given user can only request a Magic Link once every 60 seconds.

const { user, error } = await supabase.auth.signIn({
email: 'example@email.com'
})

Sign in using third-party providers.

Supabase supports OAuth logins.

const { user, error } = await supabase.auth.signIn({
// provider can be 'github', 'google', 'gitlab', or 'bitbucket'
provider: 'github'
})