Home
Softono
hyper-fetch

hyper-fetch

Open source Apache-2.0 TypeScript
1.3K
Stars
32
Forks
2
Issues
2
Watchers
1 month
Last Commit

About hyper-fetch

<h1 align="center"> <img src="./.github/assets/readme.png" alt="Hyper Fetch" /> </h1> <div align="center"> # Hyper Fetch **One SDK. Any API. Fully typed.** The type-safe API layer for TypeScript apps. Connect to REST, GraphQL, Firebase, WebSockets, SSE — all with one consistent interface and the best type safety in the ecosystem. **[Documentation](https://hyperfetch.bettertyped.com/) | [Quick Start](https://hyperfetch.bettertyped.com/docs/getting-started/quick-start) | [Guides](https://hyperfetch.bettertyped.com/docs/guides/Basic/Setup)** </div> <div align="center"> <a href="https://bettertyped.com/"> <img src="https://custom-icon-badges.demolab.com/static/v1?label=&message=BetterTyped&color=333&logo=BT" /> </a> <a href="https://github.com/BetterTyped/hyper-fetch"> <img src="https://custom-icon-badges.demolab.com/github/stars/BetterTyped/hyper-fetch?logo=star&style=flat" /> </a> <a href="https://github.com/BetterTyped/hyper-fetch/blob/main/License.md"> <img src="https://custom-i ...

Platforms

Web Self-hosted

Languages

TypeScript

Hyper Fetch

Hyper Fetch

One SDK. Any API. Fully typed.

The type-safe API layer for TypeScript apps. Connect to REST, GraphQL, Firebase, WebSockets, SSE — all with one consistent interface and the best type safety in the ecosystem.

Documentation | Quick Start | Guides


Quick Start

Define requests manually

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<{ response: { id: number; name: string }[] }>()({
  endpoint: "/users",
  method: "GET",
});

// Send it — data, error, and status are fully typed
const { data, error, status } = await getUsers.send();

Or generate from OpenAPI

npx @hyper-fetch/cli generate --url https://api.example.com/openapi.json
import { sdk } from "./generated";

// Every endpoint from your schema is available as a typed method
const { data } = await sdk.users.list.send();

Why HyperFetch?

  • 🔮 Zero guesswork — End-to-end TypeScript types from schema to response, full autocompletion, zero any
  • 📡 One interface for everything — REST, GraphQL, Firebase, WebSockets, SSE — stop learning a new library for each API
  • 💾 Data management built in — Caching, queuing, offline support, retries, and deduplication out of the box
  • Works everywhere — React, Next.js, Remix, Astro, Node.js, Bun — same API, every environment

Platinum sponsor banner

Platinum sponsors

Packages

Package Version Downloads Size
@hyper-fetch/core npm downloads size
@hyper-fetch/react npm downloads size
@hyper-fetch/sockets npm downloads size
@hyper-fetch/cli npm downloads size
@hyper-fetch/firebase npm downloads size
@hyper-fetch/firebase-admin npm downloads size
@hyper-fetch/graphql npm downloads size
@hyper-fetch/axios npm downloads size
@hyper-fetch/plugin-devtools npm downloads size

Gold sponsor banner

Gold sponsors

Examples

Fetching data

// Send and destructure — all return values are typed
const { data, error, status } = await getUsers.send();

Mutation with params and payload

// 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]" },
});

React hooks

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 <p>Loading...</p>;
  if (error) return <p>Error loading users</p>;
  return <ul>{data?.map((u) => <li key={u.id}>{u.name}</li>)}</ul>;
};

Documentation

Silver sponsor banner

Silver sponsors

Our sponsors

Sponsors

License

MIT