useSignInEmailOTP()
Use the hook useSignInEmailOTP to sign in a user with a one-time password sent via email.
- Call the
signInEmailOTPfunction with the user’s email to send a one-time password (OTP) to that email address. - The state
needsOtpwill betrue, indicating that an OTP is required. - Once the user receives the OTP via email, call the
verifyEmailOTPfunction with the email and the received OTP. - On successful verification, the user is authenticated, and
isSuccessbecomestrue.
Any error is monitored through isError and error. While the signInEmailOTP and verifyEmailOTP actions are running, isLoading equals true.
const { signInEmailOTP, verifyEmailOTP, isLoading, isSuccess, isError, error } = useSignInEmailOTP()
const signIn = async (e) => { e.preventDefault() await signInEmailOTP('john@gmail.com')}
const verify = async (e) => { e.preventDefault() await verifyEmailOTP('123456')}Parameters
Section titled “Parameters”options optional EmailOTPOptions