1.1.8 • Published 1 year ago

autowebotp v1.1.8

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Auto Web OTP

A simple library to automatically take and validate OTP codes for your website.

Installation

npm install autowebotp

Usage

React

import { webotp } from "autowebotp"
import { useEffect, useState } from "react"

export default function Home() {
  const [otp, setOtp] = useState<string>("");

  useEffect(() => {
    const abortWebOTP = webotp((receivedOtp) => {
      console.log("OTP received:", receivedOtp);
      setOtp(receivedOtp);
      alert(`OTP received: ${receivedOtp}`);
    });

    // Clean up function
    return () => {
      abortWebOTP();
    };
  }, []);

  return (
    <>
      <input 
        type="text" 
        autoComplete="one-time-code" 
        inputMode="numeric" 
        className="border-2"
        value={otp}
        onChange={(e) => setOtp(e.target.value)}
      />
    </>
  )
}
1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago