Make your AI a shadcn expert

React useDebounceCallback Hook

React useDebounceCallback hook with cancel, flush, and isPending controls. Lodash debounce under the hood. TypeScript ready.

React useDebounceCallback Hook preview

Scroll to load preview

Debounce any callback in React without stale closure issues. useDebounceCallback wraps your function with lodash debounce and returns cancel, flush, and isPending controls. Configurable delay (default 500ms), leading/trailing edge, and maxWait options. Auto-cancels on unmount to prevent memory leaks. Perfect for search inputs, autocomplete, form validation, or any rapid-fire event handler. Works with Next.js App Router and SSR. Use useDebounceValue if you need debounced state instead of a debounced function.

Install with AI

If you've connected the shadcn.io MCP server to Claude Code, Cursor, Windsurf, or any MCP-ready AI editor, prompt your agent to install this hook for you — no copy-paste, no CLI:

use shadcnio to install the use-debounce-callback hook into my project

FAQ

Was this page helpful?

Sign in to leave feedback.