Modern React Hooks Library - Boost your development with powerful, type-safe custom hooks
A comprehensive collection of 40+ production-ready React hooks designed to accelerate your development workflow. Built with TypeScript, optimized for performance, and crafted for real-world applications.
- Zero Dependencies - Pure React hooks, no external dependencies
- Performance Optimized - Built with React best practices and memoization
- Type Safe - Full TypeScript support with comprehensive type definitions
- Tree Shakeable - Import only what you need, keep your bundle size minimal
- Interactive Docs - Live examples and documentation with Storybook
npm install use-hookit
# or
pnpm add use-hookit
# or
yarn add use-hookit
import { useDebounce, useLocalStorage, useClickOutside } from 'use-hookit';
// Debounce search input
const debouncedSearch = useDebounce(searchTerm, 300);
// Persistent state (localStorage)
const [theme, setTheme, removeTheme] = useLocalStorage('theme', 'light');
// Click outside detection
const ref = useClickOutside(() => setModalOpen(false));
import {
useClickOutside,
useEventListener,
useIntersectionObserver,
useLongPress,
} from 'use-hookit/ui';
import {
useArray,
useObject,
useSet,
useMap, // Data structures
useBoolean,
useLoading,
useCopyToClipboard, // State management
useWindowSize,
useMediaQuery,
useNetworkStatus,
useGeolocation, // Browser APIs
useUrlQuery, // URL query management
} from 'use-hookit/utility';
// Boolean state
const { value, toggle, setTrue, setFalse } = useBoolean({ initialValue: false });
// Loading state
const { isLoading, startLoading, stopLoading } = useLoading();
import { useDebounce, useThrottle } from 'use-hookit/performance';
import { useIsMounted, usePrevious } from 'use-hookit/lifecycle';
import { useLocalStorage, useSessionStorage } from 'use-hookit/storage';
// LocalStorage (with TypeScript generic)
const [user, setUser, removeUser] = useLocalStorage<{ name: string; email: string }>('user', {
name: '',
email: '',
});
// SessionStorage
const [token, setToken, removeToken] = useSessionStorage('token', '');
// Array management with 20+ methods
const [array, { push, pop, filter, map, sort, reverse }] = useArray({
initialValue: [1, 2, 3],
}); // [T[], ArrayOperations<T>]
// Object state management
const [obj, { set, has, remove, merge, pick, omit }] = useObject({
initialValue: { name: 'John' },
}); // [T, ObjectOperations<T>]
// Set operations
const [set, { add, delete: remove, union, intersection, difference }] = useSet({
initialValue: ['apple', 'banana'],
}); // [Set<T>, SetOperations<T>]
// Map key-value management
const [map, { set, get, has, delete: remove, filter, map: mapValues }] = useMap({
initialValue: [['key', 'value']],
}); // [Map<K, V>, MapOperations<K, V>]
// useArray<number>
const [numbers, { push }] = useArray<number>({ initialValue: [1, 2, 3] });
// useMap<string, number>
const [scoreMap, { set }] = useMap<string, number>({ initialValue: [['math', 100]] });
// Click outside detection
const ref = useClickOutside(() => setOpen(false));
// Long press detection
const { handlers, isLongPressing } = useLongPress({
onLongPress: () => console.log('Long pressed!'),
delay: 500,
});
// Intersection observer
const { isIntersecting, ref } = useIntersectionObserver({
threshold: 0.5,
});
// Debounce values
const debouncedSearch = useDebounce(searchTerm, 300);
// Throttle callbacks
const throttledScroll = useThrottle(handleScroll, 100);
// Window size with breakpoints
const { width, height, isMobile, isDesktop } = useWindowSize();
// Media queries
const isDarkMode = useMediaQuery('(prefers-color-scheme: dark)');
// Network status
const { isOnline, isOffline } = useNetworkStatus();
// Geolocation
const { position, loading, error } = useGeolocation();
// URL ์ฟผ๋ฆฌ ํ๋ผ๋ฏธํฐ ๊ด๋ฆฌ
const { query, set, get, clear, isEmpty } = useUrlQuery({
page: 1,
search: '',
category: 'all',
});
// ํน์ ํ๋ผ๋ฏธํฐ ์ค์
set('page', 2);
// ํ๋ผ๋ฏธํฐ ๊ฐ ๊ฐ์ ธ์ค๊ธฐ
const currentPage = get('page');
// ๋ชจ๋ ํ๋ผ๋ฏธํฐ ์ ๊ฑฐ
clear();
๐ Live Storybook Documentation & Examples
๋ชจ๋ ํ ์ ์ค์๊ฐ ์์ ์ ์์ธ ๋ฌธ์๋ฅผ Storybook์์ ํ์ธํ์ธ์.
- Core: ~2KB gzipped
- Individual hooks: ~0.5-2KB each
- Tree-shakeable: Only import what you use
# Install dependencies
pnpm install
# Run tests
pnpm test
# Run Storybook locally
pnpm run storybook
# Build library
pnpm run build
- React 18.0.0 or higher
- TypeScript 4.5+ (recommended)
MIT ยฉ useHookit