useDebounceValue
Debounces a reactive value and provides a debounced setter with .cancel(), .flush(), and .isPending() controls.
Loading preview...
The useDebounceValue hook delays updates to a reactive value until delay milliseconds have passed without further changes, returning a tuple of the debounced value and the underlying debounced setter function.
Installation
Usage
Examples
Filtering a Search Input
Pass a rapidly changing input state to useDebounceValue so expensive filtering or network requests only run after the user pauses typing.
Flushing or Cancelling via the Setter
Use the second tuple item to manually update, flush, or cancel pending value transitions.
API Reference
DebounceOptions
Configuration options for controlling debounce timing and execution edges.
Property
Specification
leading?uniondefault:false
Invoke the callback on the leading edge of the timeout
Full Signature
trailing?uniondefault:true
Invoke the callback on the trailing edge of the timeout
Full Signature
maxWait?number
Maximum time in milliseconds the callback is allowed to be delayed before it is invoked
Full Signature
DebouncedFunction
Debounced setter returned as the second tuple element.
Property
Specification
cancelrequiredfunction
Cancels any pending delayed invocation
Full Signature
flushrequiredfunction
Immediately invokes any pending delayed invocation and returns the result
Full Signature
isPendingrequiredfunction
Returns
true if there is a pending delayed invocationFull Signature