SSE Hooks

useToggle

Custom hook that manages a boolean toggle state in React components.

Installation

npx sse-tool add use-toggle

Usage

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

const [isToggled, toggle, setToggle] = useToggle(); // Initial value is false
// OR
const [isToggled, toggle, setToggle] = useToggle(true); // Initial value is true
// Use isToggled in your component, toggle to switch the state, setToggle to set the state explicitly.

API

Parameters

NameTypeDescription
defaultValuebooleanThe initial value for the toggle state.

Return Value

Returns any.

A tuple containing the current state, a function to toggle the state, and a function to set the state explicitly.

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