- Fewer re-renders. Hooks update state only when needed: lazy flags, stable handlers and refs.
- Hybrid return. Many hooks can be used as a tuple or as an object — pick the shape you prefer.
- Clean effects. Subscriptions and cleanup are sensible by default; behavior is predictable.
- SSR-ready. Browser APIs are touched strictly inside effects.
npm install @webeach/react-hookspnpm install @webeach/react-hooksyarn add @webeach/react-hooksimport { useBoolean } from '@webeach/react-hooks/useBoolean';
import { useEffectCompare } from '@webeach/react-hooks/useEffectCompare';
import { useWindowEvent } from '@webeach/react-hooks/useWindowEvent';
// or
import {
useBoolean,
useEffectCompare,
useWindowEvent,
} from '@webeach/react-hooks';- Every hook is available as an individual module path (
@webeach/react-hooks/useX). Importing this way pulls only the code you need — the most predictable and compact option for any bundler (ESM and CJS). - Named import from the package root (
@webeach/react-hooks) supports tree‑shaking in bundlers that optimize ES modules (Vite/Rollup/esbuild/Webpack 5 in production). Unused exports will be removed at build time. - For CommonJS projects, we recommend per‑module imports (
require('@webeach/react-hooks/useX')) to avoid pulling extra code through the index.
useAsyncCallback, useAsyncHandler, useBoolean, useCallbackCompare, useCollection, useControlled, useDebounceCallback, useDebounceState, useDemandStructure, useDeps, useDOMEvent, useEffectCompare, useForceUpdate, useFrame, useFrameExtended, useImageLoader, useIntersectionObserver, useIsomorphicLayoutEffect, useLayoutEffectCompare, useLiveRef, useLocalStorage, useLoop, useMap, useMediaQuery, useMemoCompare, useNumber, useOutsideEvent, usePageTitle, usePageVisibility, usePatchDeepState, usePatchState, useRefEffect, useRefState, useResizeObserver, useSessionStorage, useSet, useStatus, useThrottleCallback, useThrottleState, useTimeout, useTimeoutExtended, useToggle, useUnmount, useViewportBreakpoint, useWindowEvent
useControlled, useBoolean, useNumber, useToggle, useStatus
usePatchDeepState, usePatchState
useLocalStorage, useSessionStorage
useFrame, useFrameExtended, useLoop, useTimeout, useTimeoutExtended
useDebounceCallback, useDebounceState, useThrottleCallback, useThrottleState
useAsyncCallback, useAsyncHandler, useImageLoader
useDeps, useCallbackCompare, useEffectCompare, useLayoutEffectCompare, useMemoCompare, useIsomorphicLayoutEffect
useEffectCompare, useLayoutEffectCompare, useUnmount
useDOMEvent, useWindowEvent, useOutsideEvent
useIntersectionObserver, useResizeObserver
useMediaQuery, usePageTitle, usePageVisibility, useViewportBreakpoint
useDemandStructure, useForceUpdate, useRefState
This package has a single external dependency — @webeach/collection.
- It is used only by the
useCollectionhook. - Other hooks do not import or require
collection.
Releases are automated with semantic-release.
Before publishing a new version, make sure that:
- All changes are committed and pushed to
main. - Commit messages follow Conventional Commits:
feat: ...— new featuresfix: ...— bug fixeschore: ...,refactor: ..., etc. — as needed
- The next version (
patch,minor,major) is derived automatically from the commit types.
Developed and maintained by Ruslan Martynov.
Have an idea or found a bug? Open an issue or send a pull request.
This package is distributed under the MIT License.