[NOT MAINTAINED] Minimal data fetching library with React Suspense
[NOT MAINTAINED] Minimal data fetching library with React Suspense
This project is no longer maintained. It was a long journey to explore the possibilities for data fetching with hooks and suspense, but with React 19, the official way to do data fetching with suspense is to use server components. If you need a client-side solution, check out Jotai, which provides similar capabilities to this library in its latest state.
Minimal data fetching library with React Suspense
This library provides a React hook useFetch for any async functions.
It utilizes React Suspense and FetchProvider is required with initial inputs.
The initial inputs are used to run all async function in the initial render.
Project status: Experimental. We need to collect feedbacks.
Design choices:
npm install react-hooks-fetch…FetchProvider component
Put this component higher in the component tree.
$0 FetchProviderProps
$0.initialInputs $0.childrenimport { FetchProvider } from 'react-hooks-fetch';
const App = () => (
...
);useRefetch hook
This returns only refetch part of what useFetch returns.
fn *FetchFunc*import { useFetch } from 'react-hooks-fetch';
const refetch = useRefetch(desc);
refetch('1');useFetch hook
This is the main hook to be used.
fn *FetchFunc* options {allowUndefined: boolean}?import { useFetch } from 'react-hooks-fetch';
const { input, result, refetch } = useFetch(desc);The examples folder contains working examples. You can run one of them with
PORT=8080 npm run examples:01_minimaland open in your web browser.
You can also try them in codesandbox.io: 01 02 03
See History for previous implementations.
This is also available in other languages:
No open issues yet, or sync has not completed.