Overview
onCountdown(callback, duration, options?) creates a Countdown handle scoped to the component. Call start() (or restart()) to begin — the timer does not auto-start.
Supports pause / resume, optional onTick progress, and is stopped automatically on unmount. On SSR, returns a noop countdown that ignores control calls.
vs other timers
|
API
|
Control
|
Notes
|
|---|---|---|
onTimeout
| TimerHandle | Fires once; pause/resume; auto-starts. |
onInterval
| TimerHandle | Repeats; pause/resume; auto-starts. |
onCountdown
| Countdown | Must start(); progress ticks; toast-friendly. |
Pausable countdown with progress
Start a 4s countdown with onTick progress. Pause, resume, or restart. Stops automatically if the component unmounts.