alibaba/hooks (ahooks): A React Hooks Library for Data Fetching, State and DOM
A high-quality & reliable React Hooks library. https://alibaba.github.io/hooks/
At a glance
- What is it?
- ahooks is Alibaba's TypeScript React Hooks library, MIT licensed and published on npm as ahooks. Its README lists SSR support, closure-safe function handling and a mix of basic and advanced hooks.
- Who is it for?
- Adopt ahooks if you want one TypeScript library of basic and advanced React hooks, including useRequest, instead of rewriting the same effects per project. Check the useRequest documentation before treating it as a replacement for a server-state cache such as TanStack Query, and do not expect it to cover routing or global stores.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 18 days ago.
- What is it written in?
- Mainly TypeScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 13, 2026, and from our analysis. They are not legal advice.
Star history
- alibaba/hooks14,979 ★ · +5
| Repository | 2026-09-21 | 2026-11-13 |
|---|---|---|
| alibaba/hooks | 15k | 15k |
5 Stars in the last 53 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
What ahooks Is and Who Ends Up Using It
ahooks is a collection of React Hooks written in TypeScript, published to npm under the name ahooks and developed in the alibaba/hooks repository. The README describes it as "a high-quality & reliable React Hooks library" and lists its feature set as easy learning, SSR support, special treatment for functions to avoid closure problems, advanced Hooks refined from business scenarios, a comprehensive collection of basic Hooks, and static types.
The audience is narrower than the tagline suggests. This is not a state manager. It is a set of reusable behaviours that sit between React and whatever library you already chose for fetching, storage or layout measurement. A team that keeps rewriting the same effects in every project is the natural fit.
The repository is a pnpm workspace. package.json declares "private": true at the root, so the root package is never published; the shipped artifacts come from the packages/ directory, and the build script is pnpm -r --filter=./packages/* run build. That layout matters when you want to read the source of a hook rather than the docs page.
The Mechanism: Hooks Grouped by Business Scenario
The design decision that separates ahooks from a grab bag of utility hooks is the README's phrase "advanced Hooks that are refined from business scenarios". The library is organised around recurring application problems rather than around primitives. useRequest is the clearest example: it wraps an asynchronous function and exposes the surrounding lifecycle, so the hook, not the component, owns the request lifecycle.
The second stated mechanism is "special treatment for functions, avoid closure problems". Stale closures are the classic failure of hand-written effects: a callback captures an old value and keeps calling it. ahooks says it addresses this at the library level. The README does not spell out the implementation, so treat this as a design promise rather than a documented algorithm.
The third mechanism is breadth. Alongside the advanced hooks there is what the README calls "a comprehensive collection of basic Hooks". In practice you adopt one or two advanced hooks first, then discover the basic ones while reading the sidebar. TypeScript is not decoration here: the repository's primary language is TypeScript, and the README promises "predictable static types".
Installing ahooks and Importing Your First Hook
The README gives four package managers. Pick the one your lockfile already uses; mixing them is the fastest way to get two copies of React.
$ npm install --save ahooks
# or
$ yarn add ahooks
# or
$ pnpm add ahooks
# or
$ bun add ahooksImporting is a named import from the package root. The README's usage example is exactly one line, reproduced here verbatim.
import { useRequest } from "ahooks";That is the whole documented first step: install the package, then import the hook you need by name. The README does not print a full component example, so the next thing to do is read the documentation page for the specific hook you want rather than guessing at its return shape.
If you want to run the documentation site locally instead of consuming the published package, the contributing section of the README gives the workspace commands. They require pnpm and clone the repository before building it.
$ git clone [email protected]:alibaba/hooks.git
$ cd hooks
$ pnpm run init
$ pnpm startThe README states that the dev server is then reachable at http://127.0.0.1:8000.
The use-url-state Rename Is a Real Upgrade Trap
The README carries a notice that is easy to skim past: use-url-state is now published as @ahooks.js/use-url-state, and the notice tells anyone installing or upgrading to use the new package name. That means an import of use-url-state from the main ahooks package is not the path the project now points at.
This is the kind of split that produces confusing failures. A dependency bump that looks routine can leave a component importing a hook that the maintainers have moved out. If you have use-url-state anywhere in your codebase, search for it before you touch your lockfile, and read the notice on the README and the package page for @ahooks.js/use-url-state rather than assuming the old import still resolves.
The release history reinforces that upgrades deserve attention. v3.11.0 landed on 2026-10-27, v3.10.0 on 2026-09-06, and v3.9.7 on 2026-03-23. That is a normal cadence for a library of this size, but it also means a pinned version can sit several releases behind before anyone notices a moved package.
Where ahooks Is the Wrong Tool
ahooks does not present itself as a server-state cache. The README does not describe useRequest's caching or deduplication behaviour, so check that hook's documentation before relying on it for shared server state.
It is also not a router, not a global store, and not a form library. The README's feature list is explicit about scope: basic and advanced hooks, SSR support, types. Nothing in it claims routing or persistence.
The SSR claim deserves its own caution. The README lists SSR support as a feature, but SSR correctness depends on which hook you use and where. A DOM-observation hook or one that reads window during render behaves differently on the server than a pure state hook. The feature line tells you the library was built with SSR in mind; it does not tell you that every hook in the collection is safe in your particular render path. Test the specific hook you plan to use under your framework's server render before you build on it.
How It Differs from TanStack Query and SWR
The honest comparison is with TanStack Query or SWR, because both are built around a server cache. Those libraries treat the server cache as the primary object: a query key identifies a piece of remote state, components subscribe to it, and the cache decides when to refetch, deduplicate and expire.
The README does not document how useRequest handles shared or repeated requests, so compare it against the hook's documentation page before choosing.
ahooks also covers ground beyond fetching: the README lists a comprehensive collection of basic Hooks alongside the advanced ones. That is the argument for ahooks: one dependency for the behavioural layer, with the fetching hook included rather than bolted on. If your fetching needs are already complex, the cache-first libraries are the better centre of gravity and ahooks becomes an optional companion for the non-fetching hooks.
Maintenance, Licence and Upgrade Cost
The repository is not archived, and its last push was on 2026-10-27. The most recent release in the list is v3.11.0 from 2026-10-27, with the prior two releases in September 2026 and March 2026. Read that as a project that ships when there is something to ship rather than on a fixed train.
The licence is MIT, stated in the repository metadata and backed by the LICENSE file at the repository root. MIT is permissive: it allows commercial use, modification and redistribution provided the copyright notice and permission notice are retained. That is a statement about the licence text, not legal advice; if your organisation has a policy on third-party dependencies, route it through whoever owns that policy.
Upgrade cost is dominated by two things. First, the use-url-state move to @ahooks.js/use-url-state, which is a codemod-sized change but only if you find the imports. Second, the release pace: v3.10.0 and v3.11.0 shipped less than two months apart, so read the changes between versions. The repository is a pnpm workspace with a strict preinstall guard (npx only-allow pnpm), so if you plan to contribute rather than consume, expect to work inside that toolchain.
Editorial conclusion
Adopt ahooks if you want one TypeScript library of basic and advanced React hooks, including useRequest, instead of rewriting the same effects per project. Check the useRequest documentation before treating it as a replacement for a server-state cache such as TanStack Query, and do not expect it to cover routing or global stores. Before committing, verify the use-url-state package rename, confirm your React version against the peer range in the published package.json, and check that the specific hook you need is exported from the installed version rather than only from the docs site.
Frequently asked questions
What is ahooks and who is it for?
ahooks is a TypeScript React Hooks library published on npm as ahooks and developed in the alibaba/hooks repository. It is for React teams that want basic and advanced hooks, including useRequest, from one dependency instead of rewriting those effects per project.
How do I install ahooks?
The README gives npm install --save ahooks, with yarn add ahooks, pnpm add ahooks and bun add ahooks as alternatives. Import is a named import, for example import { useRequest } from "ahooks";.
Does ahooks replace a data fetching cache like TanStack Query?
The README does not position it that way: it describes ahooks as a hooks library and says nothing about useRequest caching, so check the useRequest documentation before using it in place of a cache-first library.
What happened to use-url-state in ahooks?
The README states that use-url-state is now published as @ahooks.js/use-url-state and tells anyone installing or upgrading to use the new package name. Check your imports before upgrading.
What licence does ahooks use?
MIT. The repository metadata reports MIT and the repository root contains a LICENSE file. MIT permits commercial use, modification and redistribution as long as the copyright and permission notices are kept.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/alibaba-hooks)Star history chart for your README
[](https://hysenlabs.com/projects/alibaba-hooks)Was this useful?