1.1.8 • Published 10 months ago

autowebotp v1.1.8

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months 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

10 months ago

1.1.7

10 months ago

1.1.6

10 months ago

1.1.5

10 months ago

1.1.4

10 months ago

1.1.3

10 months ago

1.1.2

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.0

10 months ago