Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/juliencrn/usehooks-ts
React hook library, ready to use, written in Typescript.
https://github.com/juliencrn/usehooks-ts
hook hooks mdx nextjs react react-hook react-hooks reactjs typescript
Last synced: 11 days ago
JSON representation
React hook library, ready to use, written in Typescript.
- Host: GitHub
- URL: https://github.com/juliencrn/usehooks-ts
- Owner: juliencrn
- License: mit
- Created: 2020-04-15T22:53:26.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-05-01T00:35:40.000Z (6 months ago)
- Last Synced: 2024-05-01T16:30:44.759Z (6 months ago)
- Topics: hook, hooks, mdx, nextjs, react, react-hook, react-hooks, reactjs, typescript
- Language: TypeScript
- Homepage: https://usehooks-ts.com
- Size: 10.8 MB
- Stars: 5,665
- Watchers: 17
- Forks: 393
- Open Issues: 61
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome - juliencrn/usehooks-ts - React hook library, ready to use, written in Typescript. (TypeScript)
- awesome - juliencrn/usehooks-ts - React hook library, ready to use, written in Typescript. (TypeScript)
- awesome - juliencrn/usehooks-ts - React hook library, ready to use, written in Typescript. (TypeScript)
- jimsghstars - juliencrn/usehooks-ts - React hook library, ready to use, written in Typescript. (TypeScript)
README
usehooks-ts
React hook library, ready to use, written in Typescript.
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](code_of_conduct.md)
![NPM Downloads](https://img.shields.io/npm/dm/usehooks-ts)
![NPM Downloads](https://img.shields.io/npm/dt/usehooks-ts)
[![License](https://badgen.net/badge/License/MIT/blue)](https://github.com/juliencrn/usehooks-ts/blob/master/LICENSE)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/usehooks-ts)
![npm](https://img.shields.io/npm/v/usehooks-ts)
[![All Contributors](https://img.shields.io/badge/all_contributors-253-orange.svg?style=flat-square)](#contributors-)
npm i usehooks-ts
## π« Introduction
useHooks(π₯).ts is a React hooks library, written in Typescript and easy to use. It provides a set of hooks that enables you to build your React applications faster. The hooks are built upon the principles of DRY (Don't Repeat Yourself). There are hooks for most common use cases you might need.
The library is designed to be as minimal as possible. It is fully tree-shakable (using the ESM version), meaning that you only import the hooks you need, and the rest will be removed from your bundle making the cost of using this library negligible. Most hooks are extensively tested and are being used in production environments.
### Usage example
```tsx
import { useLocalStorage } from 'usehooks-ts'function Component() {
const [value, setValue] = useLocalStorage('my-localStorage-key', 0)// ...
}
```## πͺ Available Hooks
- [`useBoolean`](https://usehooks-ts.com/react-hook/use-boolean) β handles boolean state with useful utility functions.
- [`useClickAnyWhere`](https://usehooks-ts.com/react-hook/use-click-any-where) β handles click events anywhere on the document.
- [`useCopyToClipboard`](https://usehooks-ts.com/react-hook/use-copy-to-clipboard) β copies text to the clipboard using the [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API).
- [`useCountdown`](https://usehooks-ts.com/react-hook/use-countdown) β manages countdown.
- [`useCounter`](https://usehooks-ts.com/react-hook/use-counter) β manages a counter with increment, decrement, reset, and setCount functionalities.
- [`useDarkMode`](https://usehooks-ts.com/react-hook/use-dark-mode) β returns the current state of the dark mode.
- [`useDebounceCallback`](https://usehooks-ts.com/react-hook/use-debounce-callback) β creates a debounced version of a callback function.
- [`useDebounceValue`](https://usehooks-ts.com/react-hook/use-debounce-value) β returns a debounced version of the provided value, along with a function to update it.
- [`useDocumentTitle`](https://usehooks-ts.com/react-hook/use-document-title) β sets the document title.
- [`useEventCallback`](https://usehooks-ts.com/react-hook/use-event-callback) β creates a memoized event callback.
- [`useEventListener`](https://usehooks-ts.com/react-hook/use-event-listener) β attaches event listeners to DOM elements, the window, or media query lists.
- [`useHover`](https://usehooks-ts.com/react-hook/use-hover) β tracks whether a DOM element is being hovered over.
- [`useIntersectionObserver`](https://usehooks-ts.com/react-hook/use-intersection-observer) β tracks the intersection of a DOM element with its containing element or the viewport using the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).
- [`useInterval`](https://usehooks-ts.com/react-hook/use-interval) β creates an interval that invokes a callback function at a specified delay using the [setInterval API](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval).
- [`useIsClient`](https://usehooks-ts.com/react-hook/use-is-client) β determines if the code is running on the client side (in the browser).
- [`useIsMounted`](https://usehooks-ts.com/react-hook/use-is-mounted) β determines if the component is currently mounted.
- [`useIsomorphicLayoutEffect`](https://usehooks-ts.com/react-hook/use-isomorphic-layout-effect) β uses either useLayoutEffect or useEffect based on the environment (client-side or server-side).
- [`useLocalStorage`](https://usehooks-ts.com/react-hook/use-local-storage) β uses the [localStorage API](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) to persist state across page reloads.
- [`useMap`](https://usehooks-ts.com/react-hook/use-map) β manages a key-value [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) state with setter actions.
- [`useMediaQuery`](https://usehooks-ts.com/react-hook/use-media-query) β tracks the state of a media query using the [Match Media API](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia).
- [`useOnClickOutside`](https://usehooks-ts.com/react-hook/use-on-click-outside) β handles clicks outside a specified element.
- [`useReadLocalStorage`](https://usehooks-ts.com/react-hook/use-read-local-storage) β reads a value from [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage), closely related to [useLocalStorage()](https://usehooks-ts.com/react-hook/use-local-storage).
- [`useResizeObserver`](https://usehooks-ts.com/react-hook/use-resize-observer) β observes the size of an element using the [ResizeObserver API](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver).
- [`useScreen`](https://usehooks-ts.com/react-hook/use-screen) β tracks the [screen](https://developer.mozilla.org/en-US/docs/Web/API/Window/screen) dimensions and properties.
- [`useScript`](https://usehooks-ts.com/react-hook/use-script) β dynamically loads scripts and tracking their loading status.
- [`useScrollLock`](https://usehooks-ts.com/react-hook/use-scroll-lock) β A custom hook that locks and unlocks scroll.
- [`useSessionStorage`](https://usehooks-ts.com/react-hook/use-session-storage) β uses the [sessionStorage API](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage) to persist state across page reloads.
- [`useStep`](https://usehooks-ts.com/react-hook/use-step) β manages and navigates between steps in a multi-step process.
- [`useTernaryDarkMode`](https://usehooks-ts.com/react-hook/use-ternary-dark-mode) β manages ternary (system, dark, light) dark mode with local storage support.
- [`useTimeout`](https://usehooks-ts.com/react-hook/use-timeout) β handles timeouts in React components using the [setTimeout API](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout).
- [`useToggle`](https://usehooks-ts.com/react-hook/use-toggle) β manages a boolean toggle state in React components.
- [`useUnmount`](https://usehooks-ts.com/react-hook/use-unmount) β runs a cleanup function when the component is unmounted.
- [`useWindowSize`](https://usehooks-ts.com/react-hook/use-window-size) β tracks the size of the window.## π Backers
Big thanks go to all our backers! [[Become a backer](https://github.com/sponsors/juliencrn)]
Sentry
KATT
Adhi Ravishankar
great-work-told-is
## β¨ Contributors
Big thanks go to all our contributors! [[Become a contributor](https://github.com/juliencrn/usehooks-ts/blob/master/.github/CONTRIBUTING.md)]
Julien
π π» π¨ π€
a777med
π»
Nguyen Tien Dat
π»
Elias Cohenca
π
JoΓ£o Deroldo
π π»
Nishit
π»
Jon Koops
π»
LoneRifle
π»
Viktor
π€ π
Bruno Clermont
π¬
yoannesbourg
π€
Strange2x
π€
Jason Pickens
π
Sel-Vin Kuik
π
isaac
π
Bruno RZN
π» π
Nathan Manceaux-Panot
π» π
Dien Vu
π€
Oleg Kusov
π€
Matthew Guy
π€
andrewbihl
π
lancepollard
π
Mukul Bansal
π
Jean-Luc Mongrain sur la Brosse
π» π€
Nic
π
Dan Wood
π»
jo wendenbuerger
π
Andrew Nosenko
π
CharlieJhonSmith
π»
Sullivan SENECHAL
π€ π π»
Jason Long
π
kxm766
π
Quentin
π» π€ π
Daniel Lazar
π» π
Mark Terrel
π π»
Andreas Herd
π
Sonjoy Datta
π»
Ilya Belsky
π
James Barrett
π»
AbbalYouness
π»
didriklind
π» β οΈ
hexp1989
π»
Alvaro Serrano
π
Egehan DΓΌlger
π»
PabloLION
π π»
David Sanchez
π
Ajay Raja
π
Andy Merskin
π€
Avirup Ghosh
π» π
Sanne WintrΓ©n
π
Alessandro
π
Andrey Tatarenko
π
Anton Rusak
π
Mahmood Bagheri
π»
Anver Sadutt
π
Bogdan Ailincai
π»
Simeon Griggs
π
Kepro
π
Jake Lippert
π
Tu Nguyen Anh
π π»
Luke Shiels
π
Sergei Kolyago
π€
Adham Akmal Azmi
π
Alek Kowalczyk
π
Sean Callahan
π
Joshua Bean
π» π
Tim Zhao
π
Patrick
π
Bryce Dorn
π»
angusd3v
π»
Davide Di Simone
π
Jack Herrington
π
Avi Sharvit
π» π
Nicolae Maties
π
Shardul Aeer
π
Herlon Aguiar
π
Alexis Oney
π
curtvict
π»
JosuΓ© Cortina
π
Alex / KATT
π»
Mourad EL CADI
π» π
James Hulena
π
Matthew Hailwood
π» π
Michael Norrie
π
Valentin Politov
π»
Marnus Weststrate
π»
mancuoj
π
Chat Sumlin
π»
Owen Haupt
π π
ubarbaxor
π»
Michael Mior
π π
Pierre
π»
Harry B
π
Valerie
π π»
Steven Vachon
π»
Sean Kirby
β οΈ π»
Alecsander Farias
π»
Rahul Mishra
π» π π
Bryant Smith
π» π
Rob Hannay
π»
Hooriza
π» π
ShanSenanayake
π»
Philip Ghering
π»
Ladislas Dellinger
π»
Haff
π»
Lisandro
π»
Amir hossein rezaei
π»
Nicolas Macian
π π»
Nate Forsyth
π»
satelllte
π» π
Federico Panico
π»
William Pei Yuan
π»
Mihai
π» π
Habib Ogunsola
π
Ash Furrow
π»
Daniel TuruΘ
π»
Rahul Chaudhary
π π
Joshua Ojoawo
π€ π
Jack
π»
Jon Linkens
π» π
Jeongjin Oh
π
Tianning Li
π»
Lars Artmann
π
KBobovskiy
π»
β¨ Kathryn Gonzalez β¨
π
Yaroslav Chapelskyi
π
Samuel Van Erps
π
ojolowoblue
π
Andrii Kostenko
π»
Akeem Allen
π» π
trongbinhnguyen
π
Aniruddha Sil
π»
λ°μ°¬ν
π
Anish
π»
Hugo Hutri
π
Balz Guenat
π»
OtterGeorge
π»
Samay Sagar
π
Pedro Lisboa
π
Henrique Malheiros
π
Kevin Newman
π»
a503189
π
Mourad EL CADI
π»
Pedro Henrique Lopes
π»
Danbi Lee
π»
Connor Jennings
π»
Lucas Gomes
π π»
Martin Zagora
π»
KvD
π»
Alex
π»
Kacey Cleveland
π
Avirup Ghosh
π
yabbal
π»
Craig Patik
π
Soldeplata Saketos Candela
π»
TENDOUZHI
π
Marcin Wachulski
π
Salman Fazal
π
shrugs
π
hyodori
π
Eleazar βEβ Ramos
π
retnag
π
J young Lee
π
Filip Weiss
π
Marius Gundersen
π
Syed Aman Ali
π
Axel Ingadi
π
AndyP
π
ishanVaghasiya
π
Nico Martinucci
π
Shiv Bhonde | shivbhonde.eth
π
fritzmonkey
π
Rodrigo Mesquita
π
Moshe Simantov
π
Beka
π
Abdallah Alkaser
π π»
Carl Smith
π
Orlando Groppo
π
MartΔ³n Saly
π
Quinn Shanahan
π
Antoine Kingue
π
Ε½an Ε½lender
π
Sebastian Dominguez
π
James Cowan
π
Bayram Ali Basgul
π
Wyatt Castaneda
π
Tim Neville
π
Thomas Pigarelli
π
James Herdman
π
Grzegorz Pociejewski
π
RenΓ© Verheij
π
PatrykKuniczak
π
Paolo BoΕΎac
π
Rein
π
FloorianB
π
Xuan Hung
π
Monawwar Abdullah
π
Haroldo de Oliveira Pinheiro
π
Tamjid Ahmed
π
jv-lopez
π
Callum Macrae
π
bywater529
π
Kevin He
π
FredericoGauz
π
Jonathan "JonLem" Lemos
π
Xegulon
π
Tom Smedley
π
lightbluepoppy
π
Derek Oware
π
Lance Gliser
π
J. Lewis
π
Yair
π
Nishchit
π
Devofy
π
Josh Guyette
π
Dora Li
π
Kristian Gerardsson
π
James Powell
π
Boaz Poolman
π
roker15
π
Fadhil Ahmad
π
Chandler-Zhu
π
Nghi Nguyen
π
Shravan Sunder
π
Johannes5
π
sebahhpeya
π
Or Nakash
π
Erez Makavy
π
Andy Merskin
π
ChainAlert Bot
π
Taylor Morgan
π
wisdomabioye
π
Samuel QuiΓ±ones
π€
Manuel
π» π
Yurii Rybak
π
Yury Demin
π π»
Jon Tewksbury
π» π
Novac Denis
π» π
kyrylo-soulandwolf
π» π
Miguel Isidoro
π»
Yuriy Gromchenko
π»
Jacob Hummer
π€
Kyrylo Melnychuk
π π»
Luma
π»
Eliya Cohen
π»
Igor Sukharev
π
pookmish
π€
metav-drimz
π€
luckrnx09
π»
Hubert Kuczmierczyk
π€ π
dandubya
π
Darwish
π»
Jonathan Raoult
π π
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification ([emoji key](https://allcontributors.org/docs/en/emoji-key)). Contributions of any kind welcome!
## π Donate
If you find this piece of software helpful, please consider a donation. Any amount is greatly appreciated.
[![GitHub Sponsors](https://badgen.net/badge/GitHub%20Sponsors/Donate/blue)](https://github.com/sponsors/juliencrn)
[![Paypal](https://badgen.net/badge/Paypal/Donate/blue)](https://www.paypal.com/paypalme/juliencrn)
[![Stripe](https://badgen.net/badge/Stripe/Donate/blue)](https://buy.stripe.com/fZefZY8Bv32cg9O3cc)
[![Buy me a coffee](https://badgen.net/badge/Buy%20me%20a%20coffee/Donate/blue)](https://www.buymeacoffee.com/juliencrn)BTC: `bc1qwys40tnd0lxf9lr9l0t6xc63dpxyucj4x4nay0`
ETH: `0x36a85155a8300754C56395D5af24553FB18915D6`
## π License
This project is [MIT](https://github.com/juliencrn/usehooks-ts/blob/master/LICENSE) licensed.