useCountdown
Returns timer progress from 0 to 100 with pause support.
Returns timer progress from 0 to 100 with pause support.
Usage
'use client';
import { useCountdown } from '@prosazhin/pbcomponents';
function Example() {
const progress = useCountdown({ delay: 5000, paused: false });
return (
<progress
value={progress}
max={100}
/>
);
}Hook API
Parameters
| Parameter | Type / variants | Purpose | Default |
|---|---|---|---|
delay | number | Timer duration in milliseconds. | — |
paused | boolean | Pauses the timer. | — |
onComplete? | () => void | Called when the countdown finishes. | — |
enabled? | boolean | Enables the countdown. | — |
Returns
| Value | Type / variants | Purpose |
|---|---|---|
progress | number | Progress from 0 to 100. |