Generate TOTP and HOTP with browser's native Web Cryptography.
Very lightweight, 1.02 KiB / 0.59 KiB gzip with just one dependency.
See caniuse.com/cryptography for Browser support.
npm install native-browser-otp
pnpm install native-browser-otp
yarn add native-browser-otp
import { totp } from "native-browser-otp";
const code = await totp(BASE_32_SECRET);