Stop Rebuilding UI

Shadcn.io is not affiliated with official shadcn/ui

React useScript Hook

React useScript hook for dynamically loading external scripts. Load status tracking, caching, SSR safe. TypeScript ready.

Load external JavaScript files dynamically with useScript. Pass a URL and get loading status: idle, loading, ready, or error. Scripts are cached globally so multiple components requesting the same script share one network request. Existing scripts are detected and reused automatically. Options for conditional loading, custom script IDs, and cleanup on unmount. Perfect for third-party integrations like analytics, maps, payments, or social widgets. SSR safe—scripts only load client-side. Works with Next.js App Router and any React framework. Handles race conditions and duplicate script tags gracefully.

React useScript Hook preview

Scroll to load preview

Installation

FAQ

Was this page helpful?

Sign in to leave feedback.