← All open source projects

react-use

streamich/react-use

react-use is a collection of ready-made React hooks for browser APIs, state, effects, sensors, lifecycle, and everyday UI tasks.

Forks 3,272
Author streamich
Language TypeScript
License Unlicense
Synced 2026-06-27

What it is

react-use is a collection of ready-made React hooks. It covers many small tasks around browser APIs, state, effects, and user interfaces.

The project appeared after hooks arrived in React, when it became clear that many repeated patterns could be packaged as small reusable functions.

Its main task is to give developers a set of tested hooks so they do not rewrite subscriptions, timers, window-size logic, and similar glue code.

How the project is built

Inside the project are TypeScript code, documentation, demos, many hooks by category, and a package for React applications.

The collection covers browser events, local storage, media queries, state, lifecycle, animations, asynchronous operations, and other common places.

How people use it

A normal scenario is to find a hook for a task, connect it in a component, check behavior, and leave less handwritten code in the project.

For teams, react-use is useful because it reduces custom hooks that solve the same task slightly differently.

Practical example

Using a ready hook

This example shows the point of react-use: a common browser scenario can be connected through a ready hook instead of manual subscription.

Language: React TSX
import { useWindowSize } from 'react-use';

export function Viewport() {
  const { width, height } = useWindowSize();
  return <span>{width} × {height}</span>;
}

The project’s strength is breadth. One package contains many small solutions that usually spread across project utilities.

Strengths

Another advantage is TypeScript support, which makes hooks easier to use without guessing return values.

The limitation is that the whole collection is not always needed. If a project uses two hooks, dependency size and alternatives should be evaluated.

Limitations

A ready hook also does not remove the need to understand browser APIs: subscriptions, cleanup, and server rendering still need attention.

react-use best fits React projects with many small interactive scenarios where the team does not want to duplicate utilities.

Who it fits

For design systems, it is useful to choose stable hooks and wrap them in local component conventions when a unified behavior model is needed.

In the catalog, react-use matters as a collection library: its value is saving many small decisions, not introducing a large framework.

A practical start is to connect one hook in a real place, check bundle size, and see whether the code becomes easier to read.

react-use is especially useful when a team wants to standardize small interactive pieces of an interface. Window size, hover state, timers, and local storage are often rewritten in every project. A ready collection does not design the architecture for the team, but it removes repeated low-level code and leaves the component focused on the scenario.