Skip to content

naufaldi/ts-hooks-kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ts-hooks-kit

npm version npm monthly downloads bundle size GitHub stars
TypeScript GitHub Actions license

Production-ready React hooks for React 18 & 19, fully typed and tree-shakeable.
Documentation · GitHub


React applications need reliable, well-typed hooks — but maintaining them across React versions is hard. ts-hooks-kit is a batteries-included hooks library that picks up where usehooks-ts left off, providing 50 production-ready hooks with full React 18 and 19 support, zero runtime dependencies, and a migration path from usehooks-ts.

✨ Features

  • React 18 & 19: tested against both versions in CI
  • Type-safe: first-class TypeScript with full type inference
  • Tree-shakeable: import only what you use, keep bundles small
  • Zero dependencies: React peer dependency only, no runtime deps
  • Dual output: ESM + CJS builds via tsdown
  • Drop-in migration: codemod to migrate from usehooks-ts automatically

📦 Install

npm install @ts-hooks-kit/core

# or

yarn add @ts-hooks-kit/core

# or

pnpm add @ts-hooks-kit/core

⚡️ Quick Start

import { useBoolean, useLocalStorage } from '@ts-hooks-kit/core'

export function Example() {
  const [enabled, toggleEnabled] = useBoolean(false)
  const [name, setName] = useLocalStorage('name', 'ts-hooks-kit')

  return (
    <button type="button" onClick={toggleEnabled}>
      {enabled ? `Enabled for ${name}` : 'Disabled'}
    </button>
  )
}

🪝 Available Hooks

State useBoolean · useCounter · useDisclosure · useList · useMap · useQueue · useSet · useStateList · useStep · useToggle

Storage useLocalStorage · useReadLocalStorage · useSessionStorage

Browser useCopyToClipboard · useDarkMode · useDocumentTitle · useGeolocation · useMediaQuery · useNetwork · usePermission · useScreen · useScript · useScrollLock · useTernaryDarkMode · useWindowSize

DOM useClickAnyWhere · useEventListener · useHover · useIntersectionObserver · useOnClickOutside · usePageLeave · useResizeObserver

Timing useCountdown · useDebounceCallback · useDebounceValue · useIdle · useInterval · useThrottle · useTimeout

Lifecycle useEventCallback · useIsClient · useIsMounted · useIsomorphicLayoutEffect · useMemoizedFn · usePrevious · useUnmount · useUpdate · useUpdateEffect

Data useAsync · usePagination

📚 Documentation

🔄 Migration from usehooks-ts

Swap your imports automatically with the included codemod:

npx ts-hooks-kit-codemod <target-path> --dry  # preview changes
npx ts-hooks-kit-codemod <target-path>         # apply changes

The codemod rewrites usehooks-ts imports to @ts-hooks-kit/core and handles any renamed hooks.

👥 Contributors

ts-hooks-kit contributors

🙏 Credits

Built on the excellent work of usehooks-ts by Julien Caron. Forked from v3.1.1 with continued maintenance and React 19 support.

📜 License

MIT

About

Actively maintained React hooks library based on usehooks-ts, upgraded for React 18/19 compatibility

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages