SSE Hooks

useTimeout

Custom hook that handles timeouts in React components using the setTimeout API.

Installation

npx sse-hooks add use-timeout

Usage

example.ts
import { useTimeout } from "./{hooks file}";

// Usage of useTimeout hook
useTimeout(() => {
  // Code to be executed after the specified delay
}, 1000); // Set a timeout of 1000 milliseconds (1 second)

API

Parameters

Prop Default Type
callback-

() => void

The function to be executed when the timeout elapses.

delay-

number | null

The duration (in milliseconds) for the timeout. Set to null to clear the timeout.

Returns

Return Value Default Type
return-

void

Hook return value

Types Aliases

No specific type aliases defined for this component.

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