SSE Hooks

useCounter

GitHub
Custom hook that manages a counter with increment, decrement, reset, and setCount functionalities.

Installation

npx sse-hooks add use-counter

Usage

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

const { count, increment, decrement, reset, setCount } = useCounter(5);

API

Parameters

Prop Default Type
initialValue-

number

The initial value for the counter.

Returns

Return Value Default Type
count-

number

The current count value.

decrement-

() => void

Function to decrement the counter by 1.

increment-

() => void

Function to increment the counter by 1.

reset-

() => void

Function to reset the counter to its initial value.

setCount-

React.Dispatch<React.SetStateAction<number>>

Function to set a specific value to the counter.

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