Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Query | 33,717 | 19 hours ago | 46 | mit | TypeScript | |||||
🤖 Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query. | ||||||||||
Swr | 26,100 | 13 | 451 | 3 days ago | 124 | September 12, 2022 | 92 | mit | TypeScript | |
React Hooks for Data Fetching | ||||||||||
React Refetch | 3,433 | 157 | 22 | 4 months ago | 82 | January 20, 2020 | 48 | other | JavaScript | |
A simple, declarative, and composable way to fetch data for React components | ||||||||||
Use Http | 2,252 | 5 | 29 | 2 months ago | 101 | September 12, 2022 | 80 | mit | TypeScript | |
🐶 React hook for making isomorphic http requests | ||||||||||
React Async | 2,099 | 400 | 56 | 4 months ago | 90 | March 27, 2020 | 60 | isc | JavaScript | |
🍾 Flexible promise-based React data loader | ||||||||||
Rest Hooks | 1,753 | a day ago | 10 | apache-2.0 | TypeScript | |||||
Normalized state management for async data. Safe. Fast. Reusable. | ||||||||||
Cross Fetch | 1,495 | 14,308 | 1,942 | 24 days ago | 40 | April 10, 2022 | 33 | mit | JavaScript | |
Universal WHATWG Fetch API for Node, Browsers and React Native. | ||||||||||
React Async Hook | 1,130 | 22 | 25 | a month ago | 26 | September 24, 2021 | 28 | TypeScript | ||
React hook to handle any async operation in React components, and prevent race conditions | ||||||||||
Redux Query | 1,102 | 12 | 7 | 15 days ago | 70 | June 30, 2022 | 7 | other | JavaScript | |
A library for managing network state in Redux | ||||||||||
Frisbee | 1,092 | a year ago | n,ull | mit | JavaScript | |||||
:dog2: Modern fetch-based alternative to axios/superagent/request. Great for React Native. |
Hyper Fetch
Hyper Fetch
is fetching framework. What makes it unique is the typesafe design
and the ease of use
. This
library can run in the browser and on the server
with any framework. With our library fetching, architecture and
access to requests lifecycle is fabulously simple, thanks to which you can
create new components or functionalities much faster
and all of this in accordance with good practices!
Documentation Quick Start Guides API
Simple setup - Read more
Easy cancellation - Read more
Deduplicate similar requests - Read more
Queueing - Read more
Response caching - Read more
Offline First - Read more
Built-in fetcher - Read more
Authentication - Read more
Smart Retries - Read more
The easiest way to get the latest version of Hyper Fetch is to install it via yarn or npm.
npm install --save @hyper-fetch/core
or
yarn add @hyper-fetch/core
npm install --save @hyper-fetch/sockets
or
yarn add @hyper-fetch/sockets
npm install --save @hyper-fetch/core @hyper-fetch/react
or
yarn add @hyper-fetch/core @hyper-fetch/react
Package | Stats |
---|---|
Hyper Fetch |
|
Hyper Fetch Sockets |
|
React Hyper Fetch |
|
import { Client } from "@hyper-fetch/core";
// Setup our connection to the server
export const client = new Client({ url: "http://localhost:3000" });
// Create reusable requests for later use
export const postData = client.createRequest<ResponseType, RequestType, LocalErrorType, QueryParamsType>()({
method: "POST",
endpoint: "/data/:accountId",
});
export const getData = client.createRequest<ResponseType, RequestType, LocalErrorType, QueryParamsType>()({
method: "GET",
endpoint: "/user",
});
Executing previously prepared requests is very simple. We can do this using the send method.
const [data, error, status] = await getData.send();
We can attach the data to the request with methods before sending it to the server. This is helpful for building our request and attaching data to it which can be helpful when we need to create it in a few steps from data obtained during some process.
// Set the information to request (methods return request clone - NOT mutating the source)
const request = postData
.setParams({ accountId: 104 }) // Set Params
.setQueryParams({ paramOne: "test", paramTwo: "test2" })
.setData({ name: "My new entity", description: "Some description" }) // Add payload data
.send();
We can also pass them directly to the send method, which will add them to the request at once.
// OR pass dynamic data directly to '.send' method
const [data, error, status] = await postData.send({
params: { accountId: 104 },
data: { name: "My new entity", description: "Some description" },
queryParams: { paramOne: "test", paramTwo: "test2" },
});
import { useFetch } from "@hyper-fetch/react";
// Lifecycle fetching
const { data, error, loading, onSuccess, onError } = useFetch(getData);
onSuccess((data) => {
console.log(data);
});
onError((error) => {
console.log(error);
});
import { useSubmit } from "@hyper-fetch/react";
const { submit, data, error, submitting, onSubmitSuccess, onSubmitError } = useSubmit(request);
onSuccess((data) => {
console.log(data);
});
onError((error) => {
console.log(error);
});
return <button onClick={() => submit()}>Trigger request!</button>;
import { useSubmit } from "@hyper-fetch/react";
const { submit, data, error, submitting, onSubmitSuccess, onSubmitError } = useSubmit(request);
onSuccess((data) => {
console.log(data);
});
onError((error) => {
console.log(error);
});
return (
<button
onClick={() =>
submit({
params: { accountId: 104 },
data: { name: "My new entity", description: "Some description" },
queryParams: { paramOne: "test", paramTwo: "test2" },
})
}
>
Trigger request!
</button>
);
import { useSubmit } from "@hyper-fetch/react";
// Manual triggering
const { submit, data, error, submitting, onSubmitSuccess, onSubmitError } = useSubmit(request);
onSuccess((data) => {
console.log(data);
});
onError((error) => {
console.log(error);
});
const handleSubmit = (values: ValuesType, { setSubmitting }: FormikHelpers) => {
const [data, error, status] = await submit(); // Submit method returns data!
setSubmitting(false);
if (data) {
notification.success("Done!", data);
} else {
notification.success("Error!", error);
}
};
return <Form onSubmit={handleSubmit}>...</Form>;