Skip to content

ahooks

A React Hooks library of ready-made hooks for common state, request, and UI logic.alibaba/hooks

Stars
15k
Forks
2.8k
Licence
MIT
Language
TypeScript
Last update
10 days ago
Type
Library

What it is

ahooks is a TypeScript library of React Hooks, reusable functions that handle common tasks in React apps such as data requests, state, and browser behavior. Developers install it from npm and import individual hooks, for example useRequest, instead of writing that logic from scratch. The README says it supports server-side rendering and includes both basic and more advanced hooks.

  • Fetch and manage remote data with useRequest
  • Add shared state or browser-related behavior to React components using the library's hooks
  • Try hooks in an online demo before adding them to a project

Great for

  • React developers who repeatedly write data-fetching or state logic
  • Teams building business web apps who want tested, shared hooks
  • Developers who use TypeScript and want typed hook APIs
  • Projects that need server-side rendering support

Not ideal for

  • Non-React projects, because the hooks only work inside React components
  • Beginners still learning React basics, since the hooks assume understanding of React state and effects
  • Projects needing a specific hook behavior the README does not document, as the README alone does not describe the full API
Step-by-step guide: how to use ahooksInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js · React project

    Install with npm

    $ npm install --save ahooks

    Install with yarn

    $ yarn add ahooks

    Install with pnpm

    $ pnpm add ahooks

    Install with bun

    $ bun add ahooks
  2. 2

    Run it

    • Install the package in a React project using one of the install commands
    • Import a hook, for example import { useRequest } from "ahooks";
    • Call the hook inside a React component
    • Check the online demo or documentation at ahooks.js.org for examples
  3. 3

    Get the most out of it

    • Read the documentation at ahooks.js.org for the full list of hooks and options
    • Use the CodeSandbox demo linked in the README to test behavior before integrating
    • Check the Chinese docs at ahooks.js.org/zh-CN if preferred
    • For contributing, the README describes a local setup using pnpm run init and pnpm start

Downloads

Strengths

  • Installable with npm, yarn, pnpm, or bun, and imported with a single package name
  • Written in TypeScript with typed APIs, according to the README
  • Includes both basic and advanced hooks and supports SSR

Trade-offs

  • The README is brief and points to external documentation sites for full API details
  • The README notes that use-url-state has moved to a new package name, so older installs may need updating

How it compares

ProjectStarsTypeLevelUpdatedBest for
hooks (this)15kLibraryintermediate10 days agoReact developers who repeatedly write data-fetching or state logic
swr32.5kLibraryintermediate21 days agoReact developers who fetch data from APIs in components
react-hook-form44.9kLibraryintermediate5 days agoReact developers building forms with several fields
million17.7kLibraryintermediate6 months agoReact developers whose apps have many elements that update often
usehooks11.5kLibrarybeginner1.5 years agoReact developers who want ready-made hooks for common browser tasks
refine36kFrameworkintermediate2 months agoDevelopers building internal admin panels or back-office tools in React

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.