Skip to content

useCountdown

useCountdown(expiresAt): CountdownView

Defined in: useCountdown.ts:31

Derive a countdown from an absolute target timestamp. Re-renders the caller once per second while the countdown is active (until the target is reached, then a final tick to surface isExpired).

Pass null when there’s no active target; the hook is safe to always-call, and returns an inactive view.

The store should hold the stable expiresAt timestamp; this hook derives the view. That separation is the whole point — the per-tick count is not a domain fact and shouldn’t be persisted.

ParameterType
expiresAtnumber | null

CountdownView