<img src="https://badgen.net/npm/v/react-async?icon=npm&label=react-async" alt="latest version">
<img src="https://badgen.net/npm/dm/react-async" alt="montly downloads">
<img src="https://badgen.net/bundlephobia/minzip/react-async" alt="minzipped size">
<img src="https://badgen.net/npm/license/react-async" alt="license">
<img src="https://badgen.net/circleci/github/async-library/react-async/master?icon=circleci" alt="circleci status">
<img src="https://badgen.net/travis/async-library/react-async?icon=travis" alt="travis status">
<img src="https://badgen.net/codecov/c/github/async-library/react-async/master?icon=codecov" alt="code coverage">
<img src="https://www.codefactor.io/repository/github/async-library/react-async/badge" alt="code quality">
<img src="https://deepscan.io/api/teams/5549/projects/7406/branches/74183/badge/grade.svg" alt="DeepScan grade">
<img src="https://img.shields.io/badge/discord-join-7289DA.svg?logo=discord&longCache=true&style=flat" />
<img src="https://badgen.net/badge/live%20examples/available/pink?icon=now" alt="live examples">
<img src="https://badgen.net/badge/tested%20with/chromatic/fc521f" alt="Chromatic">
React component and hook for declarative promise resolution and data fetching. Makes it easy to handle every state of the asynchronous process, without assumptions about the shape of your data or the type of request. Use it with
fetch
, Axios or other data fetching libraries, even GraphQL.- Zero dependencies
- Works with promises, async/await and the Fetch API
- Now with experimental Suspense support
- Choose between Render Props, Context-based helper components or the
useAsync
anduseFetch
hooks - Debug and develop every part of the loading sequence with the React Async DevTools
- Provides convenient
isPending
,startedAt
,finishedAt
, et al metadata - Provides
cancel
andreload
actions - Automatic re-run using
watch
orwatchFn
prop - Accepts
onResolve
,onReject
andonCancel
callbacks - Supports abortable fetch by providing an AbortController
- Supports optimistic updates using
setData
- Supports server-side rendering through
initialValue
- Written in TypeScript, ships with type definitions
- Works well in React Native too!
Upgrading to v9
Version 9 comes with a minor breaking change. See Upgrading for details.
Getting started
API
Guide
Contributing
This project follows the all-contributors specification. Contributions of any kind welcome!