beautiful-react-hooks vs react-async-hook vs react-query vs react-use vs usehooks-ts
React Custom Hooks Libraries for State, Side Effects, and Async Logic
beautiful-react-hooksreact-async-hookreact-queryreact-useusehooks-tsSimilar Packages:

React Custom Hooks Libraries for State, Side Effects, and Async Logic

beautiful-react-hooks, react-async-hook, react-query, react-use, and usehooks-ts are all npm packages that provide reusable React hooks to simplify common frontend tasks. These libraries aim to reduce boilerplate and improve code quality by encapsulating logic for state management, side effects, browser APIs, and asynchronous operations. While they share overlapping goals, they differ significantly in scope, architecture, and intended use cases โ€” from general-purpose utility hooks (react-use, usehooks-ts) to specialized async and data-fetching solutions (react-async-hook, react-query). beautiful-react-hooks focuses on declarative event handling and lifecycle abstractions.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
beautiful-react-hooks08,359343 kB9a year agoMIT
react-async-hook01,187163 kB31-MIT
react-query049,4032.26 MB1763 years agoMIT
react-use043,976454 kB655a year agoUnlicense
usehooks-ts07,812251 kB127a year agoMIT

React Hook Libraries Compared: When to Use Which

Managing state, side effects, and async logic in React apps often leads to repetitive useEffect and useState patterns. The libraries beautiful-react-hooks, react-async-hook, react-query, react-use, and usehooks-ts each offer prebuilt hooks to reduce this boilerplate โ€” but they solve different problems. Letโ€™s compare them through real-world scenarios.

๐Ÿ“ก Handling Browser Events and Lifecycle: Declarative vs Manual

beautiful-react-hooks provides hooks like useEvent, useWindowResize, and useGeolocation that automatically manage event listener setup/teardown.

// beautiful-react-hooks: auto-cleanup event listener
import { useEvent } from 'beautiful-react-hooks';

function ClickTracker() {
  const onClick = useEvent('click', (event) => {
    console.log('Clicked at', event.clientX, event.clientY);
  });
  // No manual useEffect or removeEventListener needed
  return <div onClick={onClick}>Track clicks</div>;
}

react-use and usehooks-ts also offer similar hooks, but require more explicit control:

// react-use: useClick
import { useClick } from 'react-use';

function ClickTracker() {
  const ref = useRef(null);
  useClick(ref, () => console.log('Clicked'));
  return <div ref={ref}>Track clicks</div>;
}

// usehooks-ts: useEventListener
import { useEventListener } from 'usehooks-ts';

function ClickTracker() {
  const handleClick = () => console.log('Clicked');
  useEventListener('click', handleClick);
  return <div>Track clicks</div>;
}

react-async-hook and react-query donโ€™t focus on DOM events โ€” theyโ€™re purely for async and data logic.

โณ Managing Async Function States: Simple vs Advanced

For basic async calls (e.g., form submission), react-async-hook wraps functions and exposes loading, error, and result:

// react-async-hook
import { useAsyncCallback } from 'react-async-hook';

function LoginForm() {
  const login = useAsyncCallback(async (credentials) => {
    return await api.login(credentials);
  });

  if (login.loading) return <Spinner />;
  if (login.error) return <Error msg={login.error.message} />;
  return <form onSubmit={() => login.execute({ user, pass })} />;
}

react-query goes further โ€” it treats async results as server state with caching, deduplication, and background refetching:

// react-query
import { useQuery, useMutation } from '@tanstack/react-query';

function UserProfile({ userId }) {
  const { data, isLoading } = useQuery({
    queryKey: ['user', userId],
    queryFn: () => fetchUser(userId)
  });

  const mutation = useMutation({
    mutationFn: updateUser,
    onSuccess: () => {
      // Invalidate and refetch user data
      queryClient.invalidateQueries(['user', userId]);
    }
  });

  return <div>{isLoading ? '...' : data.name}</div>;
}

react-use and usehooks-ts donโ€™t provide dedicated async state hooks. Youโ€™d typically combine useState/useEffect manually or use useAsync from react-use (which is basic):

// react-use: simple async
import { useAsync } from 'react-use';

const { value, loading, error } = useAsync(() => fetchUser(id), [id]);

beautiful-react-hooks has no async utilities.

๐Ÿ’พ Local Storage and Browser APIs: Utility Coverage

react-use and usehooks-ts shine here with dozens of hooks for browser features:

// react-use
import { useLocalStorage, useNetwork, useMedia } from 'react-use';

const [darkMode, setDarkMode] = useLocalStorage('theme', 'light');
const isOnline = useNetwork().online;
const isMobile = useMedia('(max-width: 768px)');

// usehooks-ts
import { useLocalStorage, useNetwork, useMediaQuery } from 'usehooks-ts';

const [darkMode, setDarkMode] = useLocalStorage('theme', 'light');
const isOnline = useNetwork().online;
const isMobile = useMediaQuery('(max-width: 768px)');

react-query and react-async-hook donโ€™t cover these. beautiful-react-hooks includes some (e.g., useGeolocation), but far fewer than the utility-focused libraries.

๐Ÿ” Caching and Data Synchronization: Only One Game in Town

Only react-query provides automatic caching, stale-while-revalidate, pagination, and mutation rollback:

// react-query handles cache keys, deduplication, background updates
const { data } = useQuery({
  queryKey: ['posts'],
  queryFn: fetchPosts,
  staleTime: 1000 * 60 // 1 min
});

All other libraries treat async results as local component state. If two components fetch the same data, theyโ€™ll make two network requests unless you build your own cache.

๐Ÿงช TypeScript Support and Type Safety

usehooks-ts is built from the ground up in TypeScript with strict types:

// usehooks-ts: fully typed
const [value, setValue] = useLocalStorage<string>('key', 'default');

react-use also offers strong TypeScript support, though some hooks have looser inference.

react-query has excellent TypeScript integration, especially around query keys and mutation variables.

react-async-hook and beautiful-react-hooks support TypeScript but with less comprehensive typing in edge cases.

๐Ÿ›‘ Maintenance Status

As of 2024, all five packages are actively maintained with recent releases. None are deprecated.

๐Ÿ†š Summary Table

Feature / Packagebeautiful-react-hooksreact-async-hookreact-queryreact-useusehooks-ts
DOM Event Helpersโœ… RichโŒโŒโœ… Goodโœ… Good
Async State ManagementโŒโœ… Basicโœ… Advanced (caching, mutations)โœ… Basic (useAsync)โŒ
Browser API Hooksโš ๏ธ LimitedโŒโŒโœ… Extensiveโœ… Extensive
Server-State FocusโŒโŒโœ… YesโŒโŒ
TypeScript-Firstโš ๏ธ Partialโš ๏ธ Partialโœ… Excellentโœ… Strongโœ… Strict

๐Ÿ’ก Final Guidance

  • Need robust data fetching with caching? โ†’ react-query is the industry standard.
  • Building an interactive UI with lots of event listeners? โ†’ beautiful-react-hooks reduces boilerplate.
  • Wrapping simple async functions (e.g., form submits)? โ†’ react-async-hook is lightweight and sufficient.
  • Want a comprehensive utility belt for browser APIs? โ†’ Choose react-use (larger ecosystem) or usehooks-ts (cleaner TS, smaller API).

Donโ€™t mix react-query with the others for data fetching โ€” it solves that problem completely. But combining react-query with usehooks-ts (for useDebounce, useLocalStorage, etc.) is a common and effective pattern in production apps.

How to Choose: beautiful-react-hooks vs react-async-hook vs react-query vs react-use vs usehooks-ts

  • beautiful-react-hooks:

    Choose beautiful-react-hooks if you need clean, declarative hooks for DOM events (like clicks, scrolls, or window resizing) with built-in cleanup and dependency management. Itโ€™s well-suited for interactive UIs where you want to avoid manual useEffect boilerplate for event listeners, but it doesnโ€™t handle data fetching or caching.

  • react-async-hook:

    Choose react-async-hook when you want a lightweight, focused solution for managing async function states (loading, error, result) without external dependencies. Itโ€™s ideal for wrapping simple API calls or async computations in components, but lacks advanced features like caching, retries, or background refetching.

  • react-query:

    Choose react-query for robust server-state management โ€” especially when your app relies heavily on data fetching from APIs. It provides automatic caching, background updates, pagination, mutations, and devtools out of the box. Use it when you need to minimize network requests and keep UI data synchronized with backend sources.

  • react-use:

    Choose react-use if you need a broad collection of high-quality, battle-tested hooks covering browser APIs (e.g., localStorage, media queries), sensors (e.g., mouse, network status), and utilities (e.g., previous value, timeout). Itโ€™s excellent as a general-purpose hook toolkit but doesnโ€™t specialize in async or server-state management.

  • usehooks-ts:

    Choose usehooks-ts when you prefer TypeScript-first, minimal, and well-documented implementations of common custom hooks (like useLocalStorage, useDebounce, or useWindowSize). Itโ€™s a solid alternative to react-use with stricter type safety and simpler internals, but similarly avoids complex async orchestration.

README for beautiful-react-hooks

CI/CD Coverage StatusLicense:
MIT npm GitHub stars

Beautiful React Hooks


A collection of tailor-made React hooks to enhance your development process and make it faster.

Usage example

๐Ÿ‡ฌ๐Ÿ‡ง English | ๐Ÿ‡จ๐Ÿ‡ณ ็ฎ€ไฝ“ไธญๆ–‡ | ๐Ÿ‡ฎ๐Ÿ‡น Italiano | ๐Ÿ‡ช๐Ÿ‡ธ Espaรฑol | ๐Ÿ‡บ๐Ÿ‡ฆ Ukrainian | ๐Ÿ‡ง๐Ÿ‡ท Brazilian Portuguese | ๐Ÿ‡ต๐Ÿ‡ฑ Polski | ๐Ÿ‡ฏ๐Ÿ‡ต ๆ—ฅๆœฌ่ชž | ๐Ÿ‡น๐Ÿ‡ท Tรผrkรงe

๐Ÿ’ก Why?

Custom React hooks allow developers to abstract the business logic of components into single, reusable functions.
I have noticed that many of the hooks I have created and shared across projects involve callbacks, references, events, and dealing with the component lifecycle.
Therefore, I have created beautiful-react-hooks, a collection of useful React hooks that may help other developers speed up their development process.
Moreover, I have strived to create a concise and practical API that emphasizes code readability, while keeping the learning curve as low as possible, making it suitable for larger teams to use and share t -- Please before using any hook, read its documentation! --

โ˜•๏ธ Features

  • Concise API
  • Small and lightweight
  • Easy to learn

๐Ÿ•บ Install

by using npm:

$ npm install beautiful-react-hooks

by using yarn:

$ yarn add beautiful-react-hooks

Basic usage

importing a hooks is as easy as the following straightforward line:

import useSomeHook from 'beautiful-react-hooks/useSomeHook'

๐ŸŽจ Hooks

Peer dependencies

Some hooks are built using third-party libraries (such as rxjs, react-router-dom, redux). As a result, you will see these libraries listed as peer dependencies.
Unless you are using these hooks directly, you need not install these dependencies.

Contributing

Contributions are very welcome and wanted.

To submit your custom hook, make sure you have thoroughly read and understood the CONTRIBUTING guidelines.

Prior to submitting your pull request: please take note of the following

  1. make sure to write tests for your code, run npm test and npm build before submitting your merge request.
  2. in case you're creating a custom hook, make sure you've added the documentation (you may use the HOOK_DOCUMENTATION_TEMPLATE to document your custom hook).

Credits

Icon made by Freepik from www.flaticon.com