SSE Hooks

useScript

Custom hook that dynamically loads scripts and tracking their loading status.

Installation

npx sse-tool add use-script

Usage

import { useScript } from "./{hooks file}";

const scriptStatus = useScript("https://example.com/script.js", {
  removeOnUnmount: true,
});
// Access the status of the script loading (e.g., 'loading', 'ready', 'error').

API

Parameters

| Name | Type | Description | | :------ | :----------------- | :------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | | src | string | any | The source URL of the script to load. Set to null or omit to prevent loading (optional). | | options | UseScriptOptions | Additional options for controlling script loading (optional). |

Return Value

Returns UseScriptStatus.

The status of the script loading, which can be one of 'idle', 'loading', 'ready', or 'error'.

Changelog

c165d — feat: enhance useRoleGuard and useSSR hooks with additional options and documentation

30da4 — feat: add new hooks and their metadata

cf13e — feat: add custom hooks for step navigation, ternary dark mode, timeout, toggle, unmount, and window size

Built with Love • © 2026