Skip to main content

Use cases

Start with the root hook, then add a subpath only when the screen needs it.

NeedUseImportLive recipe
Stopwatch, clock, absolute deadline, pausable countdownCore@crup/react-timer-hookStopwatch
OTP resend, retry button, invite cooldownCore + duration@crup/react-timer-hook + /durationOTP resend cooldown
Human display parts like days/minutes/secondsCore + duration@crup/react-timer-hook + /durationPausable countdown
Polling or cadence callbacks while a timer is activeSchedules@crup/react-timer-hook/schedulesPolling schedule
Draft autosave or presence heartbeatSchedules@crup/react-timer-hook/schedulesAutosave heartbeat
Polling that can stop the lifecycle earlySchedules@crup/react-timer-hook/schedulesPoll and cancel
Dozens of rows with independent pause/resume/cancelTimer group@crup/react-timer-hook/groupTimer group
Checkout or reservation holdsTimer group@crup/react-timer-hook/groupCheckout holds
Per-row polling or status checksTimer group + schedules@crup/react-timer-hook/groupPer-item polling
Runtime add/update/remove of timer itemsTimer group@crup/react-timer-hook/groupDynamic items
Toast or snackbar auto-dismissTimer group@crup/react-timer-hook/groupToast auto-dismiss
Development event tracingDiagnostics@crup/react-timer-hook/diagnosticsDiagnostics

Real-world mapping

Product caseCompositionWhy
Auction card countdownCoreOne server deadline, derived from timer.now.
Auction list with pause/resume per lotTimer groupEach row owns lifecycle state and controls.
Auction status pollingSchedules or group schedulesPoll cadence is separate from UI update cadence.
Checkout reservation holdCore + durationPausable duration math and friendly display parts.
OTP resend buttonCore + durationShort local cooldown with a disabled/enabled button state.
Seat map with many expiring holdsTimer groupMany keyed holds, one scheduler.
Draft editor autosaveSchedulesA running lifecycle owns the autosave cadence and errors.
Upload/job dashboardTimer group + schedulesRows can poll status and end independently.
Focus/break timerCore + durationPausable countdown based on active elapsed time.
Live clock widgetCoreDerive new Date(timer.now).
Toast expiry with pause-on-hoverTimer groupEach toast can pause, resume, cancel, and remove.

Rule of thumb

Use one useTimer() for display-only lists when every row can derive from the same now.

Use useTimerGroup() when rows need independent state, controls, schedules, or callbacks.

Use useScheduledTimer() when the timer itself owns cadence callbacks such as polling, heartbeat checks, or autosave pings.