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
| Name | Type | Description | Example |
|---|---|---|---|
| sendCode | function | Function to send OTP code | sendCode(phoneNumber) |
| verifyCode | function | Function to verify OTP code | verifyCode(otpCode) |
| resendCode | function | Function to resend OTP code | resendCode(phoneNumber) |
| reset | function | Function to reset OTP login | reset() |
| currentStep | string | Current step of OTP login | 'send' | 'verify' | 'done' |
| sendStatus | string | Status of send OTP code | 'loading' | 'success' | 'error' |
| verifyErrorMessage | string | Error message of verify OTP code | 'Invalid OTP' |
| resendStatus | string | Status of resend OTP code | 'loading' | 'success' | 'error' |
| resendErrorMessage | string | Error message of resend OTP code | 'Invalid phone number' |
| failedAttemptCount | number | Failed attempt count | 2 |
| verifyStatus | string | Status after submitting OTP | 'loading' | 'success' | 'error' |
Usage
const {
sendCode,
verifyCode,
resendCode,
reset,
currentStep,
sendStatus,
verifyErrorMessage,
resendStatus,
resendErrorMessage,
failedAttemptCount,
} = useOtpLogin({ handleAction });