SSE Hooks

useFetch

Custom hook that provides a wrapper around the native [fetch API](https://developer.

Installation

npx sse-tool add use-fetch

Usage

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

interface User {
  id: number;
  name: string;
}

const { data, loading, error, execute } = useFetch<User>(
  "https://api.example.com/user/1",
  {
    immediate: true,
    onSuccess: (data) => console.log("User loaded:", data),
  },
);

API

Parameters

NameTypeDescription
urlstringThe URL to fetch.
optionsUseFetchOptionsOptions for customizing the request and hook behavior (optional).

Return Value

Returns UseFetchReturn.

An object containing the fetched data, loading status, error, and methods to control the request.

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