react-use: Collection of React Hooks
Pre-built hooks wrapping browser APIs and common patterns.
Learn more about React Use
react-use is a React Hooks library that provides pre-built hooks for managing state and side effects in functional components. The library wraps browser APIs and common patterns into composable hooks, allowing developers to handle sensor data, DOM measurements, keyboard input, and navigation state. It covers a broad range of use cases from device battery tracking to scroll position monitoring to media query detection. The hooks are designed to integrate directly into React functional components without requiring class-based wrappers or higher-order components.
Comprehensive sensor coverage
Provides hooks for accessing device APIs including battery status, geolocation, motion sensors, media devices, and network state. This allows functional components to directly consume hardware and browser sensor data.
DOM and layout tracking
Includes hooks for monitoring element measurements, scroll positions, intersection state, and hover status. Components can respond to layout changes and user interactions without manual event listener management.
Port of libreact patterns
The library adapts patterns from the libreact project to React Hooks, providing a migration path for developers familiar with that API while leveraging modern React functional component patterns.
import React from 'react';
import { useMouse } from 'react-use';
function MouseTracker() {
const ref = React.useRef(null);
const { docX, docY } = useMouse(ref);
return (
<div ref={ref}>
Mouse position: {docX}, {docY}
</div>
);
}Top in Frontend
Related Repositories
Discover similar tools and frameworks used by developers
Excalidraw
React canvas library with encrypted collaborative drawing.
Tailwind CSS
PostCSS framework generating utility classes from scanned templates.
next.js
File-based React framework with hybrid rendering strategies.
TanStack Table
Framework-agnostic headless table library for building datagrids.
chenyuluoyan_thin
Thin-weight Chinese font family for modern digital interfaces with graceful readability.