explaingit

alibaba/hooks

Analysis updated 2026-06-24

14,955TypeScriptAudience · developerComplexity · 2/5Setup · easy

TLDR

ahooks is a TypeScript React Hooks library from Alibaba with a large set of basic and advanced hooks for state, requests, and side effects, with SSR support.

Mindmap

mindmap
  root((ahooks))
    Inputs
      React components
      API endpoints
      Browser events
    Outputs
      Stateful hooks
      Cached requests
      Side effect handlers
    Use Cases
      Data fetching
      Form state
      Timer logic
      DOM observation
    Tech Stack
      TypeScript
      React
      SSR
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Fetch data in a React component with useRequest and get caching, polling, and retry for free

USE CASE 2

Manage form, timer, and event-listener state in a React app without writing custom hooks

USE CASE 3

Build an SSR React page that uses ahooks without hydration mismatches

USE CASE 4

Replace a pile of bespoke utility hooks across a team codebase with one well-typed shared library

What is it built with?

TypeScriptReactnpm

How does it compare?

alibaba/hooksjanpaepke/scrollmagicgvergnaud/ts-pattern
Stars14,95514,95014,990
LanguageTypeScriptTypeScriptTypeScript
Last pushed2026-05-09
MaintenanceMaintained
Setup difficultyeasyeasyeasy
Complexity2/52/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

The use-url-state package was renamed under a scoped name, so upgrading projects need to update that dependency.

In plain English

alibaba/hooks, published on npm as ahooks, is a library of React Hooks. React is a popular JavaScript framework for building user interfaces, and Hooks are small reusable functions that let a React component manage things like state, side effects, or timers without rewriting the same plumbing each time. This project, maintained inside Alibaba, collects a large set of such Hooks in one package so developers can install it and reach for ready-made building blocks instead of writing their own. The README is short and points readers at a separate documentation site at ahooks.js.org, which is available in English and Simplified Chinese. The repo itself is written in TypeScript, and the README highlights that the library has predictable static types, which means editors and the TypeScript compiler can warn you about misuse before the code runs. The feature list from the README is brief. It says the library is easy to learn and use, supports server-side rendering, gives special treatment to functions to avoid common closure problems in React, contains a comprehensive collection of basic Hooks, and adds a large number of advanced Hooks that the authors say were refined from real business scenarios. The README does not describe what each Hook does, only that they exist and are documented on the site. Installation instructions show commands for npm, yarn, pnpm, and bun, and the usage snippet shows importing a single Hook, useRequest, from the package. There is a CodeSandbox demo linked for trying the library online without setting anything up locally. A short note flags that the use-url-state package has been republished under a scoped name, so anyone upgrading needs to adjust their dependency. The rest of the README covers contributing and community. It explains how to clone the repo and run a local development server on port 8000, points to a CONTRIBUTING document, credits contributors, and shows QR-code style images for three discussion groups. The project is open source under the licence shown in the GitHub badge at the top.

Copy-paste prompts

Prompt 1
Show me how to install ahooks with pnpm and use useRequest to fetch a JSON endpoint with loading and error states
Prompt 2
Give me an ahooks example that polls an API every 5 seconds and pauses polling when the tab is hidden
Prompt 3
Convert this custom React useDebounce hook to use ahooks useDebounce and explain what changes
Prompt 4
Write a Next.js page that uses ahooks under SSR and avoids hydration warnings
Prompt 5
List the advanced ahooks I should know for building a form with validation, undo, and autosave

Frequently asked questions

What is hooks?

ahooks is a TypeScript React Hooks library from Alibaba with a large set of basic and advanced hooks for state, requests, and side effects, with SSR support.

What language is hooks written in?

Mainly TypeScript. The stack also includes TypeScript, React, npm.

How hard is hooks to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is hooks for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.