Stop Rebuilding UI

Shadcn.io is not affiliated with official shadcn/ui

React useTimeout Hook

React useTimeout hook for declarative setTimeout with auto-cleanup. Pass null to pause, callback refs for fresh state. TypeScript ready.

Schedule delayed callbacks the React way with useTimeout. Pass a callback and delay—the timeout runs once and cleans up automatically on unmount. Pass null as delay to pause or disable the timeout. Callback is stored in a ref so it always has access to fresh props/state without resetting the timer. Timer restarts when delay changes. Cleanup happens automatically on unmount or when delay becomes null. No memory leaks, no stale closures. Perfect for delayed UI updates, auto-dismiss notifications, debounced actions, redirect timers, or any one-shot delayed operation. SSR safe, works with Next.js.

React useTimeout Hook preview

Scroll to load preview

Installation

FAQ

Was this page helpful?

Sign in to leave feedback.