signInWithOtp()
Log in a user using magiclink or a one-time password (OTP).
If the {{ .ConfirmationURL }}
variable is specified in the email template, a magiclink will be sent.
If the {{ .Token }}
variable is specified in the email template, an OTP will be sent.
If you're using phone sign-ins, only an OTP will be sent. You won't be able to send a magiclink for phone sign-ins.
1const { data, error } = await supabase.auth.signInWithOtp({
2 email: 'example@email.com',
3})
Parameters#
SignInWithPasswordlessCredentialsrequired
|reflection
reflection
No description provided.
- required
object
object
No description provided.
phonerequired
string
The user's phone number.
optionsoptional
object
No description provided.
captchaTokenoptional
string
Verification token received when the user completes the captcha on the site.
dataoptional
object
A custom data object to store the user's metadata. This maps to the
auth.users.user_metadata
column.The
data
should be a JSON object that includes user-specific info, such as their first and last name.shouldCreateUseroptional
boolean
If set to false, this method will not create a new user. Defaults to true.
Properties
Properties
- required
object
object
No description provided.
emailrequired
string
The user's email address.
optionsoptional
object
No description provided.
captchaTokenoptional
string
Verification token received when the user completes the captcha on the site.
dataoptional
object
A custom data object to store the user's metadata. This maps to the
auth.users.user_metadata
column.The
data
should be a JSON object that includes user-specific info, such as their first and last name.emailRedirectTooptional
string
The redirect url embedded in the email link
shouldCreateUseroptional
boolean
If set to false, this method will not create a new user. Defaults to true.
Properties
Properties
Properties
Notes#
- Requires either an email or phone number.
- This method is used for passwordless sign-ins where a OTP is sent to the user's email or phone number.
- If you're using an email, you can configure whether you want the user to receive a magiclink or a OTP.
- If you're using phone, you can configure whether you want the user to receive a OTP.
- The magic link's destination URL is determined by the
SITE_URL
. You can modify theSITE_URL
or add additional redirect urls in your project.
Examples#
Sign in with email.#
The user will be sent an email which contains either a magiclink or a OTP or both. By default, a given user can only request a OTP once every 60 seconds.
1const { data, error } = await supabase.auth.signInWithOtp({
2 email: 'example@email.com',
3})
Sign in with SMS OTP.#
The user will be sent a SMS which contains a OTP. By default, a given user can only request a OTP once every 60 seconds.
1const { data, error } = await supabase.auth.signInWithOtp({
2 phone: '+13334445555',
3})