AsyncClient Component
useThrottleFn
Overview
useThrottleFn limits callback execution frequency while retaining the latest arguments and committed callback.
Signature
ts
function useThrottleFn<Args extends unknown[], Result>(
fn: (...args: Args) => Result,
options: ThrottleFnOptions,
): ThrottledFunction<Args, Result>;Parameters
delay defines the throttle window. leading and trailing both default to true; onError observes callback failures.
Returns
The same run, cancel, flush, and pending control object as useDebounceFn.
Behavior
Internally, maxWait equals delay, so a continuous stream cannot postpone execution indefinitely. A callback failure resets the throttle window and is rethrown after the optional onError observer runs.
SSR / RSC
No work starts during server render. Calls schedule timers only after client code invokes run.
Example
Composition
Combine it with useEventListener when the source event should remain responsive but downstream work must be bounded.