0.0.14 • Published 11 months ago

@thibault.sh/hooks v0.0.14

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@thibault.sh/hooks

A collection of performant React hooks for common use cases. Built with TypeScript.

Installation

npm install @thibaultsh/hooks

Features

State Management

  • useLocalStorageState - Persist state in localStorage
  • useSessionStorageState - Session storage state management
  • useCookieState - Cookie state management
  • useQueryParamsState - URL query parameters state

UI/Interaction

  • useClickOutside - Detect clicks outside elements
  • useHover - Track element hover state
  • useKeyPress - Keyboard input handling
  • useKeyCombo - Keyboard shortcuts
  • useLongPress - Long press detection

Layout/Viewport

  • useMediaQuery - Responsive design helper
  • useWindowSize - Window dimensions tracking
  • useScrollPosition - Scroll position tracking
  • useContainerScroll - Container scroll management
  • useElementSize - Element size observer
  • useIntersectionObserver - Viewport intersection
  • useResizeObserver - Element resize detection

Utility

  • useAsync - Async operation wrapper
  • useDebounce - Value debouncing
  • useThrottle - Action throttling
  • useTimer - Timer management
  • useInterval - Interval handling
  • useEventListener - Event subscription

Usage

import { useLocalStorageState, useMediaQuery } from '@thibault.sh/hooks';

function App() {
  const [theme, setTheme] = useLocalStorageState<'light' | 'dark'>('theme', 'light');
  const isMobile = useMediaQuery('(max-width: 768px)');

  return (
    <div>
      <button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>
        Toggle theme
      </button>
      {isMobile && <div>Mobile view</div>}
    </div>
  );
}

Documentation

For detailed documentation, visit thibault.sh/hooks

License

MIT © Thibault Mathian

0.0.14

11 months ago

0.0.10

11 months ago

0.0.11

11 months ago

0.0.12

11 months ago

0.0.13

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.1

12 months ago