npm i usehooks-ts
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.
import { useLocalStorage } from 'usehooks-ts'
function Component() {
const [value, setValue] = useLocalStorage('my-localStorage-key', 0)
// ...
}
useBoolean()
useClickAnyWhere()
useCopyToClipboard()
useCountdown()
useCounter()
useDarkMode()
useDebounce()
useDebounceCallback()
useDebounceValue()
useDocumentTitle()
useEventCallback()
useEventListener()
useHover()
useIntersectionObserver()
useInterval()
useIsClient()
useIsMounted()
useIsomorphicLayoutEffect()
useLocalStorage()
useLockedBody()
useMap()
useMediaQuery()
useOnClickOutside()
useReadLocalStorage()
useResizeObserver()
useScreen()
useScript()
useSessionStorage()
useStep()
useTernaryDarkMode()
useTimeout()
useToggle()
useUnmount()
useWindowSize()
Big thanks go to all our backers! [Become a backer]
Sentry |
KATT |
Adhi Ravishankar |
great-work-told-is |
Big thanks go to all our contributors! [Become a contributor]
This project follows the all-contributors specification (emoji key). Contributions of any kind welcome!
This project is MIT licensed.