
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
How to get it
- 1
Install with a package manager
You'll need: Node.js · React project
Install with npm
$ npm install --save ahooksInstall with yarn
$ yarn add ahooksInstall with pnpm
$ pnpm add ahooksInstall with bun
$ bun add ahooks - 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
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
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| hooks (this) | 15k | Library | intermediate | 10 days ago | React developers who repeatedly write data-fetching or state logic |
| swr | 32.5k | Library | intermediate | 21 days ago | React developers who fetch data from APIs in components |
| react-hook-form | 44.9k | Library | intermediate | 5 days ago | React developers building forms with several fields |
| million | 17.7k | Library | intermediate | 6 months ago | React developers whose apps have many elements that update often |
| usehooks | 11.5k | Library | beginner | 1.5 years ago | React developers who want ready-made hooks for common browser tasks |
| refine | 36k | Framework | intermediate | 2 months ago | Developers 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.