Skip to content
Comparisons2 min readUpdated

@danixsoft/hooks vs ahooks

The short answer

ahooks, maintained by Alibaba, is a large and well-engineered hooks library whose standout feature is useRequest — a fully featured async manager with caching, polling, retries and debouncing built in. @danixsoft/hooks is smaller and simpler, with zero runtime dependencies and a basic useFetch rather than a request framework. Choose ahooks if you want its async layer; choose @danixsoft/hooks if you want lean utilities and prefer a dedicated library like TanStack Query for data fetching.

ahooks is not really a competitor to a utility hook collection — it is closer to a framework with a hooks-shaped API. That distinction determines which one you should install.

Different problems, similar packaging

@danixsoft/hooksahooks
ScopeUtility hooks for common UI problemsA broad toolkit including an async layer
Async storyuseFetch — data, error, loading, abort on unmountuseRequest — caching, polling, retry, debounce, dependent requests
Runtime dependenciesNoneSeveral
MaintainerDanixSoft (independent)Alibaba
Docs languageEnglishEnglish and Chinese
Bundle postureTree-shakeable, tiny per hookTree-shakeable, but larger units
LicenceMITMIT

useRequest is the real decision

Nearly every ahooks-versus-alternative decision comes down to one hook. useRequest handles caching, polling, retries, debouncing, dependent requests, manual triggering and loading-state delays — a genuinely large amount of behaviour that most applications need in some form.

Our useFetch does not attempt that. It gives you data, error and loading, and aborts the request when the URL changes or the component unmounts. That is the right size for a utility library and clearly not enough for a data-heavy application.

The third option

If you want a serious async layer, TanStack Query is more capable than either library's built-in offering — request deduplication, background refetching, optimistic updates and a devtools panel. Pairing TanStack Query with a lean utility library is a common and effective combination.
A pairing that works well
1// Data layer: purpose-built.
2import { useQuery } from '@tanstack/react-query';
3
4// UI utilities: small and dependency-free.
5import { useDebounce, useMediaQuery, useClickOutside } from '@danixsoft/hooks';
6
7function ProductSearch() {
8  const [query, setQuery] = useState('');
9  const debounced = useDebounce(query, 300);
10  const { data, isLoading } = useQuery({
11    queryKey: ['products', debounced],
12    queryFn: () => searchProducts(debounced),
13  });
14  // …
15}

When ahooks is the better fit

  • You want `useRequest` specifically and do not want to add a separate data library.
  • You are already in the Ant Design ecosystem, where ahooks is the natural companion.
  • Your team reads Chinese documentation, which is first-class rather than a translation.
  • You want a large toolkit from one vendor with a single support surface.

When the leaner library is the better fit

  • You already use TanStack Query or SWR. Adding ahooks means two async layers competing for the same job.
  • Zero runtime dependencies is a requirement, not a preference.
  • You want utilities, not a framework. Adopting a framework-shaped library is a bigger architectural commitment than installing a few hooks.
  • Your app is touch-heavy. Swipe, touch and pointer hooks are first-class here.

Key takeaway

Ask what you want the library to own. If the answer includes your data-fetching architecture, ahooks or TanStack Query. If it is small stateful UI logic, a lean utility collection is the better shape.

Can I use ahooks and @danixsoft/hooks together?

Yes. Both are tree-shakeable, so importing useRequest from one and useSwipe from the other costs only those hooks. Just avoid using both libraries' versions of the same hook in one codebase — pick one per concern so behaviour stays predictable.

Does @danixsoft/hooks plan to add caching and polling to useFetch?

No. Doing that properly means request deduplication, cache invalidation and background refetching, which is a different library. TanStack Query already does it well, and duplicating it badly would serve nobody.

Is ahooks only for Ant Design projects?

No, it works in any React application. The Ant Design association reflects a shared maintainer, not a technical coupling.

Keep reading