A hook for grabbing OTP codes from the user device.

as of today, its on limited availability but you can add it as progressive enhancement noting would happen if browser doesn't support it.

you need to follow this sms format in order for this work:

Your verification code is 123456.

@domain #code

for example for my website,it would be like this:

Your verification code is 123456.

@mhl5.vercel.app #123456

Installation

pnpm dlx shadcn@latest add https://mhl5.vercel.app/r/useOtp.json

Usage

import { useOtp } from "@/hooks/useOtp";

useOtp((code) => {
  form.setFieldValue("otp", code);
});