useFetch vs useAsync vs React Query
Lightweight hooks vs a full data library. Use this guide to avoid over-engineering client data.
At a glance
useFetch
Declarative URL fetch with loading/error, abort, refetch. Ideal for simple REST reads.
useAsync / useAsyncFn
Wrap any Promise (not only fetch). Auto-run or imperative execute.
React Query / TanStack Query
Cache, background refetch, staleTime, mutations, infinite queries, Devtools. App-scale data.
Pick when…
- useFetch — Few endpoints, no shared cache, App Router already does server fetch for first paint.
- useAsync — Non-HTTP async (IDB, workers) or one-off client jobs.
- React Query — Many screens share server data, need cache invalidation, optimistic updates, or offline-ish UX.
Related library docs
React Query (external)
Not part of all-hook — shown so you know when to leave the library for a full cache layer.
react-query.sketch.tsx
// TanStack Query sketch (external library)
const { data, isLoading } = useQuery({
queryKey: ['users'],
queryFn: () => fetch('/api/users.json').then((r) => r.json()),
staleTime: 30_000,
});Starter import
imports
import { useFetch } from '@/hooks';
import { useAsync } from '@/hooks';
import { useAsyncFn } from '@/hooks';
import { useMutation } from '@/hooks';