SSE Hooks

useInterval

Custom hook that creates an interval that invokes a callback function at a specified delay using the setInterval API.

Installation

npx sse-hooks add use-interval

Usage

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

const handleInterval = () => {
  // Code to be executed at each interval
};
useInterval(handleInterval, 1000);

API

Parameters

Prop Default Type
callback-

() => void

The function to be invoked at each interval.

delay-

number | null

The time, in milliseconds, between each invocation of the callback. Use null to clear the interval.

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