AsyncClient Component
useThrottle
Overview
useThrottle constrains a rapidly changing value to one publication per configured time window.
Signature
ts
function useThrottle<T>(
value: T,
options: {
delay: number;
leading?: boolean;
trailing?: boolean;
},
): T;Parameters
delay defines the window. leading and trailing both default to true.
Returns
The most recently published value, initialized with the first input.
Behavior
It uses the debounce scheduler with maxWait equal to delay, guaranteeing progress while values keep changing.
SSR / RSC
SSR returns the input value without scheduling work. Timers begin after client commit.
Example
Composition
Use useWindowSize or useEventListener as the source, then throttle rendering of expensive derived UI.