Shadcn.io is not affiliated with official shadcn/ui
React useInterval Hook
React useInterval hook for declarative setInterval. Pass null to pause, auto-cleanup on unmount. No stale closures. TypeScript ready.
Run intervals the React way without setInterval headaches. useInterval takes a callback and delay in milliseconds—pass null to pause. Callback is stored in a ref so it always has access to fresh props and state. No stale closure bugs. Auto-clears on unmount or delay change. Perfect for polling APIs, auto-saving drafts, countdown timers, slideshow carousels, or any periodic task. Declarative start/stop with null delay. SSR safe—interval only runs client-side. Works with Next.js App Router and any React framework.
React useInterval Hook preview
Installation
Related Components
React useTimeout Hook
Declarative setTimeout management
React useCountdown Hook
Countdown timer with controls
React useCounter Hook
Counter with increment/decrement
React useBoolean Hook
Boolean state with toggle helpers
React useEventCallback Hook
Stable callback reference
React useUnmount Hook
Run cleanup on unmount
FAQ
Was this page helpful?
Sign in to leave feedback.