Skip to main content

Timers

useDebounce

Debounce a value — the returned value updates only after delay ms of stability:

const debouncedSearch = useDebounce(searchTerm, 250);

Use the debounced value in effects or child props to avoid excessive work.

useTimeout / useInterval

Schedule callbacks with stable timer handles:

const schedule = useTimeout(0);

schedule(() => reconnect(), 1000);

const every = useInterval(1000);
every(() => tick(), 1000);

Default delay argument sets the initial duration when omitted in the schedule call pattern used internally by @ekz/api WebSocket reconnect.

When to use which

HookUse case
useDebounceInput fields, filter text
useDebouncedEffectSide effects tied to changing input
useTimeoutOne-shot delayed actions
useIntervalPolling, clocks, periodic refresh