0.0.14 • Published 6 months ago

@thibault.sh/hooks v0.0.14

Weekly downloads
-
License
MIT
Repository
github
Last release
6 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

6 months ago

0.0.10

7 months ago

0.0.11

7 months ago

0.0.12

7 months ago

0.0.13

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.9

7 months ago

0.0.8

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.7

7 months ago

0.0.6

7 months ago

0.0.1

7 months ago