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.
React useTimeout Hook preview
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.
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-timeout hook into my projectRelated Components
React useInterval Hook
Declarative setInterval
React useDebounceValue Hook
Debounce state values
React useDebounceCallback Hook
Debounce function calls
React useCountdown Hook
Countdown timer with controls
React useBoolean Hook
Boolean state with helpers
React useToggle Hook
Toggle between values
FAQ
Was this page helpful?
Sign in to leave feedback.