useScript
Load an explicitly configured script with shared status and ownership.
Callers using the same resolved URL share one script. A null source or disabled hook stays idle. No URL is built in, and Storybook uses a local inert fixture. The copied example includes the public file location and contents to create in your app.
Usage
Examples
Playground
API
3 options
1 return value
Accessibility
Provide text for loading/error states and an alternative when an integration is unavailable.
Notes
- Removing a script tag cannot undo code it already ran. Prefer retaining shared libraries.
- Pre-existing scripts are never removed. Mark known external script state with data-gaudi-script-status="ready" or wait for its load/error event.
- Failed retained scripts stay error; use a new URL or removeOnUnmount to release the failed entry before retrying.
Related
useDocumentTitleSet a document title and restore the previous owner on cleanup.useIsClientFalse on the server and during hydration, true on the client.useIsMobileTrue below the 768px phone breakpoint.useIsMountedA stable getter for whether this hook is currently mounted.useMediaQueryTrack a CSS media query, SSR-safe.useOnlineStatusWhether the browser reports a network connection.