OTP resend cooldown
Use the core hook for local cooldowns such as OTP resend, login retry, invite resend, or "try again" buttons.
OTP resend cooldownLive
OTP resend
Ready to resend
Requests sent1
Cooldown15s
Buttonenabled
const cooldownMs = 15_000;
const timer = useTimer({
autoStart: true,
updateIntervalMs: 250,
endWhen: snapshot => snapshot.elapsedMilliseconds >= cooldownMs,
});
const canResend = timer.isEnded || timer.isIdle;
return (
<button disabled={!canResend} onClick={timer.restart}>
{canResend ? 'Resend OTP' : 'Wait'}
</button>
);