Skip to content

Latest commit

Β 

History

History
82 lines (57 loc) Β· 3.6 KB

File metadata and controls

82 lines (57 loc) Β· 3.6 KB

Note

We prefer English language for all communication.

Contributing to reactuse

Thanks for your interest in contributing to reactuse! This document explains how to report issues, set up the project locally, and submit a Pull Request.

Creating an issue

Before creating an issue, please make sure the problem is not already reported.

  • Bug report β€” provide a minimal reproduction using StackBlitz or CodeSandbox, describe expected vs actual behavior, and include your environment (React version, browser, OS).
  • Feature request β€” add a motivation section and a few usage examples showing how the hook or API would be used.

Sending a Pull Request

  1. fork and clone the repository
  2. create a development branch from main
  3. install dependencies from the root of the repo (Node 24.x and pnpm@11 are recommended):
   pnpm install

Note: this is a pnpm workspace (monorepo). The command installs dependencies for all packages under packages/*.

  1. build the package you are editing using its workspace filter from the root of the repo:
   pnpm --filter <PACKAGE_NAME> run build

Replace <PACKAGE_NAME> with the relevant package name. The main packages are:

  • @siberiacancode/reactuse β€” the core hook library (packages/hooks)
  • @siberiacancode/docs β€” the documentation site (packages/docs)
  • @siberiacancode/cli / useverse β€” the CLI for adding hooks (packages/cli)

There are also handy shortcuts in the root package.json:

   pnpm core:build:js   # build the core library
   pnpm docs:build      # build the documentation site
   pnpm cli:build       # build the CLI and generate its registry
  1. make changes, then run the checks locally:
   pnpm lint            # lint all packages
   pnpm unit-test       # run unit tests across all packages
   pnpm format          # format with prettier
  1. commit your changes (a husky + lint-staged pre-commit hook will lint and format staged files automatically)
  2. push your feature branch and open a Pull Request targeting main
  3. link your PR to the issue using a closing keyword or describe the motivation and changes in the comment (example: fix #74)
  4. wait until a maintainer reviews it

Creating a new hook

The goal of reactuse is to provide a large set of production-ready, TypeScript-first, SSR-compatible React hooks. Adding a new hook follows the same flow as Sending a Pull Request, plus a few conventions:

  • each hook lives in its own directory inside the hooks package, named exactly after the hook (e.g. useCounter/)
  • a hook directory should contain:
    • the hook implementation (useCounter.ts)
    • tests (useCounter.test.ts)
    • a demo/example component used by the docs
  • export the new hook from the package entry point so it ships with the library and is picked up by the CLI registry
  • make sure the hook is tree-shakeable and works in SSR (no direct access to window/document at module load β€” guard browser APIs inside effects)

After adding a dependency, run pnpm install from the repo root. To add a dependency to a specific package, use:

pnpm --filter <PACKAGE_NAME> add <LIBRARY>

If you're building an adapter around a particular library, add it as a peer dependency:

pnpm --filter <PACKAGE_NAME> add --save-peer <LIBRARY>