Introduction
The@zayne-labs/toolkit-react package provides a rich set of React hooks, utilities, and Zustand integrations designed to simplify common patterns in React development.
Installation
This package requires React 19.0.0 or higher as a peer dependency.
Package Structure
The package is organized into three main modules:Hooks (Main Export)
Import hooks from the main package entry:Utilities
Import utilities from the/utils subpath:
Zustand Integrations
Import Zustand helpers from the/zustand subpath:
Key Features
State Management Hooks
useToggle, useDisclosure, useControllable, and more for managing component state
Performance Hooks
useDebounce, useThrottle variants for optimizing event handlers and state updates
Storage Hooks
useStorageState for seamless localStorage/sessionStorage integration with React
Effect Utilities
useMountEffect, useEffectOnce, useAsyncEffect for lifecycle management
Categories
State Hooks
useToggle- Boolean state toggleuseDisclosure- Modal/drawer state with scroll controluseControllableState- Controlled/uncontrolled component patternuseStorageState- Synced storage stateuseSearchParams- URL search params management
Performance Hooks
useDebouncedFn/useDebouncedState- Debounced callbacks and stateuseThrottleByTimeout/useThrottleByTimer/useThrottleByFrame- Throttled callbacksuseCallbackRef- Stable callback reference
Effect Hooks
useMountEffect- Run effect on mount onlyuseUnmountEffect- Run cleanup on unmountuseEffectOnce- Run effect exactly once (strict mode safe)useAsyncEffect- Async effect handlinguseAfterMountEffect- Run effect after initial mountuseLifeCycle- Complete lifecycle hook
Browser API Hooks
useClickOutside- Detect clicks outside elementsuseCopyToClipboard- Clipboard API integrationuseIsHydrated- SSR hydration detectionuseScrollObserver- Scroll event observation
Advanced Hooks
createCustomContext- Type-safe context creationuseComposeRefs- Combine multiple refsuseConstant- Lazy initializationuseStore- External store subscription
Next Steps
Explore Hooks
Browse all available hooks with examples
Utilities
Learn about React utilities and helpers
Zustand Integration
Integrate with Zustand state management