Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
U

usehooks-ts

> 前端框架
Open source

React hook library, ready to use, written in Typescript.

7.8K stars0 likes2 views
WebsiteGitHub

About

React hook library, ready to use, written in Typescript.




bash
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

typescript
import { useLocalStorage } from 'usehooks-ts'

function Component() {
  const [value, setValue] = useLocalStorage('my-localStorage-key', 0)

  // ...
}

Available Hooks

  • useBoolean — handles boolean state with useful utility functions.
  • useClickAnyWhere — handles click events anywhere on the document.
  • useCopyToClipboard — copies text to the clipboard using the Clipboard API.
  • useCountdown — manages countdown.
  • useCounter — manages a counter with increment, decrement, reset, and setCount functionalities.
  • useDarkMode — returns the current state of the dark mode.
  • useDebounceCallback — creates a debounced version of a callback function.
  • useDebounceValue — returns a debounced version of the provided value, along with a function to update it.
  • useDocumentTitle — sets the document title.
  • useEventCallback — creates a memoized event callback.
  • useEventListener — attaches event listeners to DOM elements, the window, or media query lists.
  • useHover — tracks whether a DOM element is being hovered over.
  • useIntersectionObserver — tracks the intersection of a DOM element with its containing element or the viewport using the Intersection Observer API.
  • useInterval — creates an interval that invokes a callback function at a specified delay using the setInterval API.
  • useIsClient — determines if the code is running on the client side (in the browser).
  • useIsMounted — determines if the component is currently mounted.
  • useIsomorphicLayoutEffect — uses either useLayoutEffect or useEffect based on the environment (client-side or server-side).
  • useLocalStorage — uses the localStorage API to persist state across page reloads.
  • useMap — manages a key-value Map state with setter actions.
  • useMediaQuery — tracks the state of a media query using the Match Media API.
  • useOnClickOutside — handles clicks outside a specified element.
  • useReadLocalStorage — reads a value from localStorage, closely related to useLocalStorage().
  • useResizeObserver — observes the size of an element using the ResizeObserver API.
  • useScreen — tracks the screen dimensions and properties.
  • useScript — dynamically loads scripts and tracking their loading status.
  • useScrollLock — A custom hook that locks and unlocks scroll.
  • useSessionStorage — uses the sessionStorage API to persist state across page reloads.
  • useStep — manages and navigates between steps in a multi-step process.
  • useTernaryDarkMode — manages ternary (system, dark, light) dark mode with local storage support.
  • useTimeout — handles timeouts in React components using the setTimeout API.
  • useToggle — manages a boolean toggle state in React components.
  • useUnmount — runs a cleanup function when the component is unmounted.
  • useWindowSize — tracks the size of the window.

Backers

Big thanks go to all our backers! [Become a backer]


Sentry

KATT

Adhi Ravishankar

great-work-told-is

✨ Contributors

Big thanks go to all our contributors! [Become a contributor]


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

Issues· 130 open

View all issuesOpen on GitHub
  • #55

    Dependency Dashboard

    Updated Sep 28, 2026
  • #712

    [QUESTION] this library no longer mantained?

    bugUpdated Sep 1, 2026
  • #549

    [BUG] useLocalStorage's setValue should be callable in render phase (like a normal `useState`)

    bugUpdated Apr 14, 2026
  • #703

    [BUG] useDebounceCallback does not debounce when the options object is unstable

    bugUpdated Jan 9, 2026
  • #646

    [BUG] useScrollLock locks scroll forever in development (React Strict mode)

    bugUpdated Jan 8, 2026
  • #656

    [BUG] useDebounceCallback doesn't seem to memoize the callback function

    bugUpdated Oct 22, 2025
  • #639

    [BUG] useDebouncedCallback isPending() is true even though it was cancelled

    bugUpdated Oct 6, 2025
  • #663

    [BUG] useOnClickOutside doesn't allow null ref

    bugUpdated Sep 5, 2025
  • #701

    [BUG] useMediaQuery SSR case

    bugUpdated Aug 13, 2025
  • #687

    [BUG] useUnmount() writes to a ref unsafely during render

    bugUpdated Jul 12, 2025

> Tags

TypeScripthookhooksmdxnextjs

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 1, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架