Have ideas to improve npm?Join in the discussion! »

@monadstech/react-native-use-otp-verify
TypeScript icon, indicating that this package has built-in type declarations

1.0.10 • Public • Published

react-native-use-otp-verify

Wrapper Hook for react-native-otp-verify

Make yourself familiar with react-native-otp-verify before using this hook .

Installation

yarn add react-native-otp-verify @monadstech/react-native-use-otp-verify

or

npm i react-native-otp-verify @monadstech/react-native-use-otp-verify

then Follow instruction of react-native-otp-verify first

Usage

Basic Example

import React from 'react';
import {useOtpVerify} from '@monadstech/rn-use-otp-verify';
 
const OtpConfirm = () => {
  const [otp, setOtp] = React.useState('');
  const [autoDetectedOtp, autoDetectError] =  useOtpVerify() ;
 
  React.useEffect(() => {
    if (autoDetectedOtp) {
      setOtp(autoDetectedOtp);
    }
  }, [autoDetectedOtp, handleLogin]);
 
  ...
};
 

OTP Parser

Default otpParser checks for following regex : /(\d+)[\s]is|is[\s](\d+).?/g

i.e. otp SMS must be one of following formats

  • .... OTP is 2098 ....

  • .... 2098 is OTP ....

However, you can pass a custom otpParser to useOtpVerify hook.

this otpParser must accept sms as argument and return otp as string or empty string.

LICENSE

MIT LICENSE

Install

npm i @monadstech/react-native-use-otp-verify

DownloadsWeekly Downloads

9

Version

1.0.10

License

MIT

Unpacked Size

7.5 kB

Total Files

7

Last publish

Collaborators

  • avatar
  • avatar