⚡ Fetching and realtime data exchange framework.
⚡ Fetching and realtime data exchange framework.
import { createClient } from "@hyper-fetch/core";
// Create a client — this is the single entry point for all your API calls
const client = createClient({ url: "https://api.example.com" });
// Define a typed request — response shape is inferred everywhere from here
const getUsers = client.createRequest()({
endpoint: "/users",
method: "GET",
});
// Send it — data, error, and status are fully typed
const { data, error, status } = await getUsers.send();npx @hyper-fetch/cli generate --url https://api.example.com/openapi.jsonimport { sdk } from "./generated";
// Every endpoint from your schema is available as a typed method
const { data } = await sdk.users.list.send();anyHyper Fetch is the data layer inside Hype Stack, the full-stack template I build alongside it.
// Send and destructure — all return values are typed
const { data, error, status } = await getUsers.send();// Params go in the URL, data goes in the body — both fully typed
const { data, error, status } = await createUser.send({
params: { teamId: 1 },
data: { name: "Jane", email: "[email protected]" },
});import { useFetch } from "@hyper-fetch/react";
const UserList = () => {
// useFetch triggers the request on mount and returns typed state
const { data, loading, error } = useFetch(getUsers);
if (loading) return
Loading...
;
if (error) return
Error loading users
;
return
{data?.map((u) =>
{u.name}
)}
;
};No open issues yet, or sync has not completed.