Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A set of smart React hooks for performant UIs (React 18+)

License

Notifications You must be signed in to change notification settings

webeach/react-hooks

Repository files navigation


💎 Highlights

  • 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.

📦 Installation

npm install @webeach/react-hooks

or

pnpm install @webeach/react-hooks

or

yarn add @webeach/react-hooks

📥 Import

ES Modules

import { 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';

CommonJS

const { useBoolean } = require('@webeach/react-hooks/useBoolean');
const { useEffectCompare } = require('@webeach/react-hooks/useEffectCompare');
const { useWindowEvent } = require('@webeach/react-hooks/useWindowEvent');
// or
const { useBoolean, useEffectCompare, useWindowEvent } = require('@webeach/react-hooks');

🌿 Tree‐shaking

  • 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.

🛠 Hooks

Alphabetical

By category

State — simple primitives

State — object patterns

State — collections

State — storage (persistence)

Timers, loops & frames

Rate limiting (throttle/debounce)

Async operations

Dependency optimization

Lifecycle

Refs

Events

Observers

Page & document

Utilities


🧩 Dependencies

This package has a single external dependency@webeach/collection.

  • It is used only by the useCollection hook.
  • Other hooks do not import or require collection.

🔖 Releasing

Releases are automated with semantic-release.

Before publishing a new version, make sure that:

  1. All changes are committed and pushed to main.
  2. Commit messages follow Conventional Commits:
  • feat: ... — new features
  • fix: ... — bug fixes
  • chore: ..., refactor: ..., etc. — as needed
  1. The next version (patch, minor, major) is derived automatically from the commit types.

👤 Author

Developed and maintained by Ruslan Martynov.

Have an idea or found a bug? Open an issue or send a pull request.


📄 License

This package is distributed under the MIT License.

About

A set of smart React hooks for performant UIs (React 18+)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

AltStyle によって変換されたページ (->オリジナル) /