Loading...
Loading...
Loading...
Debounce a value by a given delay. Useful for search inputs and API calls.
Install
npx bouncekit@latest add usedebounceImport
import { useDebounce } from "@/hooks/use-debounce.ts"import { useDebounce } from "@/hooks/use-debounce"
const debouncedSearch = useDebounce(searchTerm, 300)
useEffect(() => {
fetchResults(debouncedSearch)
}, [debouncedSearch])API Reference
| Prop | Type | Required | Description |
|---|---|---|---|
value | T | yes | The value to debounce. |
delay | number | — | Delay in milliseconds. Default: 500. |
Source
src/hooks/use-debounce.ts