Home

Awesome

<div align="center">

@react-hookz/web

NPM Version NPM Downloads NPM Dependents Build Coverage Types Tree Shaking

× DOCS × DISCORD × CHANGELOG ×

</div>

@react-hookz/web is a library of general-purpose React hooks built with care and SSR compatibility in mind.

Install

This one is pretty simple, everyone knows what to do:

npm i @react-hookz/web
# or
yarn add @react-hookz/web

As hooks was introduced to the world in React 16.8, @react-hookz/web requires - you guessed it - react and react-dom 16.8+. Also, as React does not support IE, @react-hookz/web don't either.

Usage

This package distributed with ESNext language level and ES modules system. It means that depending on your browser target you might need to transpile it. Every major bundler provides a way to transpile node_modules fully or partially. Address your bundler documentation for more details.

You can import hooks two ways:

// from the root of package
import { useMountEffect } from '@react-hookz/web';
// or single hook directly
import { useMountEffect } from '@react-hookz/web/useMountEffect/index.js';

In case your bundler supports tree-shaking (most of modern does) - both variants are equal and only necessary code will get into your bundle. Direct hook imports should be considered otherwise.

Migrating from react-use

@react-hookz/web was built as a spiritual successor of react-use by one of its former maintainers.

Coming from react-use? Check out our migration guide.

Hooks list

Contributors

<!-- readme: collaborators,contributors,semantic-release-bot/-,lint-action/- -start --> <table> <tr> <td align="center"> <a href="https://github.com/xobotyi"> <img src="https://avatars.githubusercontent.com/u/6178739?v=4" width="100;" alt="xobotyi"/> <br /> <sub><b>Anton Zinovyev</b></sub> </a> </td> <td align="center"> <a href="https://github.com/JoeDuncko"> <img src="https://avatars.githubusercontent.com/u/6749768?v=4" width="100;" alt="JoeDuncko"/> <br /> <sub><b>Joe Duncko</b></sub> </a> </td> <td align="center"> <a href="https://github.com/ArttuOll"> <img src="https://avatars.githubusercontent.com/u/60509537?v=4" width="100;" alt="ArttuOll"/> <br /> <sub><b>Arttu Olli</b></sub> </a> </td> <td align="center"> <a href="https://github.com/kylemh"> <img src="https://avatars.githubusercontent.com/u/9523719?v=4" width="100;" alt="kylemh"/> <br /> <sub><b>Kyle Holmberg</b></sub> </a> </td> <td align="center"> <a href="https://github.com/wesgro"> <img src="https://avatars.githubusercontent.com/u/595567?v=4" width="100;" alt="wesgro"/> <br /> <sub><b>Jake Ketcheson</b></sub> </a> </td> <td align="center"> <a href="https://github.com/Rey-Wang"> <img src="https://avatars.githubusercontent.com/u/45580554?v=4" width="100;" alt="Rey-Wang"/> <br /> <sub><b>Rey Wang</b></sub> </a> </td> <td align="center"> <a href="https://github.com/AndreasNel"> <img src="https://avatars.githubusercontent.com/u/17763359?v=4" width="100;" alt="AndreasNel"/> <br /> <sub><b>Andreas Nel</b></sub> </a> </td> <td align="center"> <a href="https://github.com/fengkx"> <img src="https://avatars.githubusercontent.com/u/16515468?v=4" width="100;" alt="fengkx"/> <br /> <sub><b>Fengkx</b></sub> </a> </td></tr> <tr> <td align="center"> <a href="https://github.com/paul-sachs"> <img src="https://avatars.githubusercontent.com/u/11449728?v=4" width="100;" alt="paul-sachs"/> <br /> <sub><b>Paul Sachs</b></sub> </a> </td> <td align="center"> <a href="https://github.com/Myzel394"> <img src="https://avatars.githubusercontent.com/u/50424412?v=4" width="100;" alt="Myzel394"/> <br /> <sub><b>Null</b></sub> </a> </td> <td align="center"> <a href="https://github.com/MichalTarasiuk"> <img src="https://avatars.githubusercontent.com/u/69385846?v=4" width="100;" alt="MichalTarasiuk"/> <br /> <sub><b>Michał Tarasiuk</b></sub> </a> </td> <td align="center"> <a href="https://github.com/KonradLinkowski"> <img src="https://avatars.githubusercontent.com/u/26126510?v=4" width="100;" alt="KonradLinkowski"/> <br /> <sub><b>Konrad Linkowski</b></sub> </a> </td> <td align="center"> <a href="https://github.com/jpwallace22"> <img src="https://avatars.githubusercontent.com/u/93415734?v=4" width="100;" alt="jpwallace22"/> <br /> <sub><b>Justin Wallace</b></sub> </a> </td> <td align="center"> <a href="https://github.com/JoshuaStewartEntelect"> <img src="https://avatars.githubusercontent.com/u/92043787?v=4" width="100;" alt="JoshuaStewartEntelect"/> <br /> <sub><b>Joshua Stewart</b></sub> </a> </td> <td align="center"> <a href="https://github.com/dantman"> <img src="https://avatars.githubusercontent.com/u/53399?v=4" width="100;" alt="dantman"/> <br /> <sub><b>Daniel Friesen</b></sub> </a> </td> <td align="center"> <a href="https://github.com/ChloeMouret"> <img src="https://avatars.githubusercontent.com/u/63965373?v=4" width="100;" alt="ChloeMouret"/> <br /> <sub><b>Null</b></sub> </a> </td></tr> <tr> <td align="center"> <a href="https://github.com/punkle"> <img src="https://avatars.githubusercontent.com/u/553697?v=4" width="100;" alt="punkle"/> <br /> <sub><b>Brian Fletcher</b></sub> </a> </td> <td align="center"> <a href="https://github.com/birant"> <img src="https://avatars.githubusercontent.com/u/29652801?v=4" width="100;" alt="birant"/> <br /> <sub><b>Birant İyigün</b></sub> </a> </td> <td align="center"> <a href="https://github.com/lensbart"> <img src="https://avatars.githubusercontent.com/u/20876627?v=4" width="100;" alt="lensbart"/> <br /> <sub><b>Bart Lens</b></sub> </a> </td> <td align="center"> <a href="https://github.com/axelboc"> <img src="https://avatars.githubusercontent.com/u/2936402?v=4" width="100;" alt="axelboc"/> <br /> <sub><b>Axel Bocciarelli</b></sub> </a> </td> <td align="center"> <a href="https://github.com/akd-io"> <img src="https://avatars.githubusercontent.com/u/30059155?v=4" width="100;" alt="akd-io"/> <br /> <sub><b>Anders Kjær Damgaard</b></sub> </a> </td></tr> </table> <!-- readme: collaborators,contributors,semantic-release-bot/-,lint-action/- -end -->