otp-auto-fetch-input
v0.1.4
Published
Animated OTP input for React with WebOTP auto-fetch support
Maintainers
Readme
otp-auto-fetch-input
Animated OTP input component for React with WebOTP SMS auto-fetch support.
Install
npm install otp-auto-fetch-inputUsage
import { useState } from "react";
import { OtpInput } from "otp-auto-fetch-input";
import "otp-auto-fetch-input/styles.css";
export default function VerifyOtp() {
const [otp, setOtp] = useState("");
return (
<OtpInput
length={6}
value={otp}
onChange={(next) => setOtp(next)}
onComplete={(code) => {
console.log("OTP complete:", code);
}}
autoFetch
/>
);
}Props
length(default6): number of OTP digits.value: controlled OTP value.onChange(nextValue, source): triggered on manual/paste/WebOTP fill.onComplete(otp, source): called when all digits are present.autoFetch(defaulttrue): enables WebOTP auto-fetch on supported browsers.fetchTimeoutMs(default60000): abort timeout for WebOTP listener.autoFocus(defaulttrue): focus first empty digit on mount/update.allowPaste(defaulttrue): allows full OTP paste.disabled: disable input.className: wrapper class override.inputClassName: slot class override.onError(error): receives non-abort WebOTP errors.
WebOTP Notes
- Works only in secure contexts (
https) and compatible mobile browsers. - SMS should include your domain and OTP, for example:
Your verification code is 123456.
@example.com #123456Semantic Versioning
This package follows SemVer (MAJOR.MINOR.PATCH).
PATCH: bug fixes (0.1.0 -> 0.1.1)MINOR: backward-compatible features (0.1.0 -> 0.2.0)MAJOR: breaking API changes (0.1.0 -> 1.0.0)
Release commands:
npm run release:patch
npm run release:minor
npm run release:majorOr let standard-version infer bump type from commits:
npm run releasePublish Pipeline (GitHub Actions)
Automation files:
.github/workflows/ci.yml: validates build on pull requests andmainpushes..github/workflows/publish.yml: publishes to npm onv*.*.*tag pushes.
Required GitHub secret:
NPM_TOKEN: npm automation token with publish access.
Typical release flow:
# 1) Create version + changelog + tag (example patch)
npm run release:patch
# 2) Push commits and tags
git push --follow-tagsWhen the vX.Y.Z tag reaches GitHub, publish workflow runs and pushes the package to npm.
