Skip to content
Design System
GitHub

useDebounce

v0.15.1Beta

A value, or a function call, that waits until changes pause: a search sent when the typing stops, not on every key.

Nothing searched yet

Use debounce search

Install
npx shadcn add @syncrobotic/use-debounce

Overview

When to use

  • A search sent to a server when the typing stops (autocomplete's debounce uses it).
  • Autosave after edits pause.

Use something else

  • Something the person must see at once: update it directly, never debounced.

Usage rules

  • Debounce what goes to a server (a search, an autosave), never what the person sees: the text box updates on every key.
  • 300 ms for typing. A clear button and Enter do not wait: cancel() or flush().
  • Answers can return out of order: keep only the one for the latest query.

Changelog

  • 0.15.12026-11-21useDebouncedCallback keeps its timer and pending arguments in a closure instead of refs read during render, so it is safe under the React Compiler. Same behaviour: one stable function per delay, always calling the latest fn.
  • 0.15.02026-11-19First release: useDebouncedValue and useDebouncedCallback (with cancel and flush).

How to upgrade