useSignInEmailOTP()
Use the useSignInEmailOTP composable 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 errors during the sign-in or verification process are tracked using isError and error. While the signInEmailOTP and verifyEmailOTP actions are in progress, isLoading is true.
Example
Section titled “Example”const { signInEmailOTP, verifyEmailOTP, error } = useSignInEmailOTP()
const requestOtp = async (e: Event) => { e.preventDefault() await signInEmailOTP(email.value)}
const confirmOtp = async (e: Event) => { e.preventDefault() await verifyEmailOTP(email.value, otp.value)}Parameters
Section titled “Parameters”options optional NestedRefOfValue<undefined | EmailOTPOptions>