@jutech-devs/react-hooks
v2.0.2
Published
A comprehensive collection of 30+ modern, production-ready React hooks for enhanced development experience
Maintainers
Readme
@jutech-devs/hooks
The ultimate collection of 42 production-ready React hooks for modern web development. From basic utilities to advanced AI capabilities.
🚀 Installation
npm install @jutech-devs/hooks
# or
yarn add @jutech-devs/hooks📖 Quick Start
import { useToggle, useFetch, useDarkMode } from '@jutech-devs/hooks';
function App() {
const [isOpen, { toggle }] = useToggle();
const { data, loading } = useFetch('/api/users');
const { isDark, toggleTheme } = useDarkMode();
return (
<div className={isDark ? 'dark' : 'light'}>
<button onClick={toggle}>
{isOpen ? 'Close' : 'Open'} Modal
</button>
<button onClick={toggleTheme}>Toggle Theme</button>
{loading ? 'Loading...' : data?.length} users
</div>
);
}🎯 Hook Categories
🔧 Basic Utilities
useToggle- Boolean state managementuseDebounce- Value debouncingusePrevious- Track previous valuesuseCountdown- Timer functionalityuseHover- Mouse hover detection
💾 Storage & Persistence
useLocalStorage- localStorage with React syncuseSessionStorage- sessionStorage with React syncuseDarkMode- Complete theme system
🌐 Network & Data
useFetch- Smart HTTP requests with cachinguseAsync- Async operation managementuseWebSocket- Real-time WebSocket connectionsuseWebRTC- Video/audio communication
🎨 UI & Interactions
useClickOutside- Outside click detectionuseWindowSize- Responsive window dimensionsuseIntersectionObserver- Element visibilityuseDrag- Drag & drop functionalityuseGesture- Advanced touch gesturesuseSpring- Physics-based animations
📱 Device & Hardware
useIsMobile- Mobile device detectionuseGeolocation- GPS location trackinguseBattery- Battery status monitoringuseNetworkState- Network connection infouseCamera- Camera access & captureusePermission- Browser permission management
⌨️ Input & Events
useKeyboardShortcut- Hotkey combinationsuseCopyToClipboard- Clipboard operationsuseSpeechRecognition- Voice inputuseIdle- User activity detectionuseScrollPosition- Scroll tracking
📝 Forms & Validation
useFormValidation- Real-time form validationuseFileUpload- File upload with progress
🚀 Performance
useVirtualList- Handle large datasetsuseWorker- Web Workers for background tasks
📱 Responsive Design
useMediaQuery- Custom media queriesuseIsSmall- Small screen detectionuseIsTablet- Tablet detectionuseIsDesktop- Desktop detectionusePrefersDarkMode- System theme preferenceusePrefersReducedMotion- Accessibility preference
🔔 Notifications
useNotification- Browser notifications
🧠 Advanced Patterns
useStateMachine- State machine implementationuseUndoRedo- Undo/redo functionalityuseObservable- Reactive programminguseP2P- Peer-to-peer networking
🤖 AI & Machine Learning
useML- Neural networks in the browseruseComputerVision- Image analysis & object detectionuseNLP- Natural language processinguseRecommendationEngine- Personalization algorithms
📚 Detailed Examples
Basic Usage
// Toggle state
const [isVisible, { toggle, setTrue, setFalse }] = useToggle(false);
// Debounced search
const [search, setSearch] = useState('');
const debouncedSearch = useDebounce(search, 300);
// Local storage
const [user, setUser] = useLocalStorage('user', null);Network Operations
// Fetch with caching
const { data, loading, error, refetch } = useFetch('/api/posts', {
cache: true,
immediate: true
});
// WebSocket connection
const { sendMessage, lastMessage, isConnected } = useWebSocket('ws://localhost:8080');
// Async operations
const { execute, loading, data, error } = useAsync(async (id) => {
return await api.getUser(id);
});UI Interactions
// Click outside detection
const ref = useClickOutside(() => setIsOpen(false));
// Drag and drop
const { isDragging, position, dragRef } = useDrag();
// Intersection observer
const [setNode, entry] = useIntersectionObserver({
threshold: 0.5,
freezeOnceVisible: true
});Device APIs
// Geolocation
const { latitude, longitude, error } = useGeolocation({
enableHighAccuracy: true,
watch: true
});
// Camera access
const { stream, startCamera, takePhoto, isStreaming } = useCamera();
// Battery status
const { level, charging, supported } = useBattery();Advanced Features
// Form validation
const { values, errors, setValue, isValid } = useFormValidation(
{ email: '', password: '' },
{
email: [(v) => v.includes('@') ? null : 'Invalid email'],
password: [(v) => v.length >= 8 ? null : 'Too short']
}
);
// State machine
const { state, send, can } = useStateMachine({
id: 'toggle',
initial: 'inactive',
states: {
inactive: { on: { TOGGLE: 'active' } },
active: { on: { TOGGLE: 'inactive' } }
}
});
// Computer vision
const { detectObjects, detectFaces, analyzeScene } = useComputerVision();
const objects = await detectObjects(imageElement);🎯 Key Features
✅ TypeScript First - Full type safety and IntelliSense
✅ Zero Dependencies - Lightweight and fast
✅ SSR Compatible - Works with Next.js, Remix, etc.
✅ Tree Shakeable - Import only what you need
✅ Production Ready - Battle-tested in real applications
✅ Comprehensive - 42 hooks covering every use case
✅ Modern APIs - WebRTC, WebWorkers, AI, and more
✅ Performance Optimized - Minimal re-renders
🔧 Requirements
- React 16.8.0 or higher
- TypeScript 4.0+ (optional but recommended)
📄 License
MIT © JuTech Devs
🤝 Contributing
Contributions are welcome! Please read our contributing guidelines.
📞 Support
For support, please open an issue on GitHub or contact us at [email protected]
