Skip to main content

useOtpLogin

prerequisites​

You need to have an OTP login extension installed in your app.

Hooks​

useOtpLogin hook is used to implement OTP login in your app.

Properties​

NameTypeDescriptionExample
sendCodefunctionFunction to send OTP codesendCode(phoneNumber)
verifyCodefunctionFunction to verify OTP codeverifyCode(otpCode)
resendCodefunctionFunction to resend OTP coderesendCode(phoneNumber)
resetfunctionFunction to reset OTP loginreset()
currentStepstringCurrent step of OTP login'send' | 'verify' | 'done'
sendStatusstringStatus of send OTP code'loading' | 'success' | 'error'
verifyErrorMessagestringError message of verify OTP code'Invalid OTP'
resendStatusstringStatus of resend OTP code'loading' | 'success' | 'error'
resendErrorMessagestringError message of resend OTP code'Invalid phone number'
failedAttemptCountnumberFailed attempt count2
verifyStatusstringStatus after submitting OTP'loading' | 'success' | 'error'

Usage​

  const {
sendCode,
verifyCode,
resendCode,
reset,
currentStep,
sendStatus,
verifyErrorMessage,
resendStatus,
resendErrorMessage,
failedAttemptCount,
} = useOtpLogin({ handleAction });