SSE Hooks

useBoolean

GitHub
Custom hook that handles boolean state with useful utility functions.

Installation

npx sse-hooks add use-boolean

Usage

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

const { value, setTrue, setFalse, toggle } = useBoolean(true);

API

Parameters

Prop Default Type
defaultValue

false

boolean

The initial value for the boolean state (default is false).

Returns

Return Value Default Type
setFalse-

() => void

Function to set the boolean state to false.

setTrue-

() => void

Function to set the boolean state to true.

setValue-

React.Dispatch<React.SetStateAction<boolean>>

Function to set the boolean state directly.

toggle-

() => void

Function to toggle the boolean state.

value-

boolean

The current boolean state 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