Stop Rebuilding UI

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

Scroll to load preview

Installation

FAQ

Was this page helpful?

Sign in to leave feedback.