Privy enables users to login to your application with SMS or email. With Privy, your application can verify ownership of a user’s email address or phone number to send them notifications, campaigns, and more to keep them activated.
To authenticate your users with a one-time passcode (OTP) sent to their phone number, use the useLoginWithSms
hook.
The phone number of the user to log in. Must follow specific formatting conventions (see below).
Whether to disable the ability to sign up with the phone number.
A promise that resolves when the code is sent.
The sendCode
method requires a phoneNumber
string param that must follow these formatting conventions:
(+)1
to the phone number will still be read as a US phone number.+${countryCode}
to the beginning of the input value.+
that denotes a custom country code.The one-time passcode sent to the user’s phone number.
A promise that resolves when the user is logged in.
Track the state of the OTP flow via the state
variable returned by the
useLoginWithSms
hook.
The current state of the OTP flow.
The error that occurred during the OTP flow.
You can optionally pass callbacks into the useLoginWithSms
hook to run custom logic after a successful login or to handle errors that occur during the flow.
onComplete
The user object corresponding to the authenticated user.
Whether the user is a new user or an existing user.
Whether the user entered the application already authenticated.
The method used by the user to login.
The account corresponding to the loginMethod used.
onError
The error that occurred during the login flow.