hyper-fetch is a free, open source api development & testing project written in TypeScript and released under Apache-2.0. It has 1,344 GitHub stars, 32 forks and 1 open issues, and was last pushed 5 days ago. On this registry it ranks #138 of 189 tracked projects in API Development & Testing, with 5 head-to-head comparisons available. It gained 11 stars over the last 9 tracked days.

What is hyper-fetch?

Hyper Fetch is an Apache-2.0 licensed TypeScript framework that unifies HTTP fetching, caching, realtime sockets and mocking behind a single typed client, aimed at TypeScript teams building React, Next.js, Remix, Astro, Node.js or Bun applications who want one data layer instead of a stack of separate libraries.

What it is

Hyper Fetch is a fetching and realtime data exchange framework published to npm as @hyper-fetch/core, with a companion code generation package run through npx @hyper-fetch/cli generate. A single createClient() call acts as the entry point for all API calls, and requests are declared with client.createRequest()() by passing an endpoint and method. From that declaration the response, payload, query parameters and error shapes are inferred, so send() returns fully typed data, error and status values. It describes itself as working with REST, OpenAPI, GraphQL, tRPC, oRPC, Hono, Elysia, Firebase, Firebase Admin, Axios, sockets and SSE, and runs on React, Next.js, Remix, Astro, Node.js and Bun.

The concrete problem it solves is library sprawl in the data layer. As the project's own framing puts it, a typical app glues together a fetch wrapper, a query cache, a socket client, a codegen step and a mocking library, each bringing its own types, its own retry logic and its own bugs. Hyper Fetch replaces that assembly with one typed layer: the fetch or Axios wrapper, TanStack Query or SWR, a separate socket client, OpenAPI codegen and MSW-style hand-written mocks all collapse into the same client, so a type declared once flows into send(), hooks, cache and devtools.

Key capabilities

  • Requests are defined through createClient() and client.createRequest()(), with URL parameters checked at compile time so that /users/:userId makes userId a required argument.
  • OpenAPI schemas become typed clients through npx @hyper-fetch/cli generate --url https://api.example.com/openapi.json, producing a createSdk factory where every endpoint is available as a typed request such as sdk.users.$get.send().
  • Server routers type createSdk directly for tRPC, oRPC, Hono and Elysia, so no codegen step is needed in those setups.
  • Server state handling includes a cache with stale time, background revalidation, in-flight request deduplication, a persisted cache through lazyStorage, optimistic() updates that roll back on failure, useInfiniteFetch for pagination and useStream for streamed responses.
  • Network resilience is configurable per request with setRetry() and setRetryTime(), an offline queue that replays requests when connectivity returns, cancellation by abort key, and upload and download progress events with time estimates.
  • Realtime traffic uses one API for WebSockets and SSE with typed listeners and emitters, self-managed reconnects, and message batching or latest-only delivery before messages reach React.
  • Tooling ships alongside the client: HyperFlow devtools showing requests, cache and queue live, setMock() on any request to return data and status without a network call, and an ESLint plugin that catches empty or misspelled generic types.

Who uses it and how

  • React and Next.js teams use the built-in hooks and cache instead of adding TanStack Query or SWR, with SSR hydration included for server-rendered applications.
  • Backend-driven teams point the CLI at an OpenAPI document and generate a typed SDK rather than hand-maintaining client wrappers per endpoint.
  • Full-stack TypeScript teams running tRPC, oRPC, Hono or Elysia routers derive their client types straight from the server, removing a codegen step from the build.
  • Applications facing unreliable connectivity rely on the offline queue and retry configuration, where requests issued offline wait and replay on reconnection.
  • Realtime products use typed socket listeners and emitters with message batching to avoid render floods in React components.

Getting started

Install the core package with npm install @hyper-fetch/core, create a client with createClient({ url: "https://api.example.com" }), define a request and await its send(). Projects with an OpenAPI schema can instead run npx @hyper-fetch/cli generate --url and use the generated createSdk factory.

How it compares

The tools it consolidates are named directly in its own documentation: Axios and fetch wrappers, TanStack Query and SWR, standalone socket clients, OpenAPI codegen and MSW. Those are separate dependencies with separate type systems and retry behaviour, while Hyper Fetch offers one typed layer with swappable adapters over the same request model. Teams that already standardise on those individual libraries are effectively choosing between a smaller set of focused dependencies and a single integrated one.

When to use it — and when not to

There is no database, object storage or mail server to operate, because this is a client-side library rather than a hosted service; the operational cost is instead a commitment to its abstractions across requests, cache, sockets and mocks. Teams not writing TypeScript gain little, since compile-time parameter checking and schema-derived types are the core value. The project is also small — roughly 1,300 stars and 32 forks, with a single open issue and maintenance tied to one author's Hype Stack template — so teams needing a large contributor base or long-term vendor-style support should weigh that before adopting it.

project readme (upstream, from github) — read inline

Quick Start · Documentation · Guides · Discord

GitHub stars npm version Monthly downloads of all packages Bundle size of @hyper-fetch/core TypeScript License Follow on Twitter

🚀 Quick Start

npm install @hyper-fetch/core

Define requests manually

import { createClient } from "@hyper-fetch/core";

// Create a client. It is the single entry point for all your API calls
const client = createClient({ url: "https://api.example.com" });

// Define a typed request. The 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();

Generate from OpenAPI or backend types

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

const sdk = createSdk(client);

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

Platinum sponsor banner

</a>

Platinum sponsors

</a>

💥 Why HyperFetch?

A typical app glues together a fetch wrapper, a query cache, a socket client, a codegen step and a mocking library. Each one brings its own types, its own retry logic and its own bugs. Hyper Fetch is one typed layer for all of it.

You usually combine With Hyper Fetch you get
fetch or an Axios wrapper createClient() with swappable adapters
TanStack Query or SWR Cache, deduplication, retries and React hooks built in
A socket client Typed Socket listeners and emitters
OpenAPI codegen npx @hyper-fetch/cli generate
A tRPC, oRPC, Hono or Eden client createSdk typed from your router
MSW and hand-written mocks setMock() on any request

🔮 Types you never write twice

  • Zero guesswork - Params, payload, query params, response and error are typed on every request. No any
  • URL params checked at compile time - /users/:userId makes userId required. Typos fail the build
  • Typed from your schema - Point the CLI at OpenAPI and every endpoint becomes a typed request
  • Typed from your server - tRPC, oRPC, Hono and Elysia routers type createSdk directly. No codegen step
  • One request, every layer - The type you declare once flows into send(), hooks, cache and devtools

💾 Server state handled for you

  • Cache with stale time - Fresh data comes from cache. Stale data revalidates in the background
  • Persisted cache - Plug in lazyStorage and the cache survives reloads
  • No duplicate calls - Identical requests in flight share one response
  • Optimistic updates - Show the result now. optimistic() rolls it back if the request fails
  • Pagination and streams - useInfiniteFetch for endless lists, useStream for streamed responses

📴 Built for bad networks

  • Retries - Set attempts and delay per request with setRetry() and setRetryTime()
  • Offline queue - Requests sent offline wait and replay when the connection returns
  • Cancel anything - Abort one request or a whole group by its abort key
  • Progress - Upload and download progress events with time estimates

📡 Realtime on the same model

  • WebSockets and SSE, one API - Typed listeners and emitters for both protocols
  • Reconnects on its own - Configurable reconnect attempts and timing
  • No render floods - Batch messages or keep only the latest one before they reach React

🧪 Tooling included

  • Devtools - HyperFlow shows every request, the cache and the queue live
  • Mocking - setMock() on any request returns your data and status with no network call
  • ESLint plugin - Catches empty and misspelled generic types on requests and clients
  • Works everywhere - React, Next.js, Remix, Astro, Node.js and Bun. SSR hydration included

🔌 Works with


Try other BetterTyped projects

Hyper Fetch is the data layer inside Hype Stack, the full-stack template I build alongside it.

Gold sponsor banner

</a>

Gold sponsors

</a>

📦 Packages

Package Version Downloads Size
@hyper-fetch/core
The client, requests, cache, queues, retries and offline support
npm downloads size
@hyper-fetch/react
useFetch, useSubmit, useListener and the rest of the React hooks
npm downloads size
@hyper-fetch/sockets
Typed WebSocket and Server-Sent Events listeners and emitters
npm downloads size
@hyper-fetch/cli
Generates a typed SDK from an OpenAPI schema
npm downloads size
@hyper-fetch/graphql
GraphQL queries and mutations with gql documents
npm downloads size
@hyper-fetch/trpc
tRPC procedures as typed requests, inferred from your router
npm downloads size
@hyper-fetch/orpc
oRPC procedures as typed requests, inferred from your router
npm downloads size
@hyper-fetch/hono
A typed SDK from your Hono app type. Types only, no server code
npm downloads size
@hyper-fetch/elysia
A typed SDK from your Elysia app type. Types only, no server code
npm downloads size
@hyper-fetch/firebase
Firestore and Realtime Database from the browser
npm downloads size
@hyper-fetch/firebase-admin
Firestore and Realtime Database from the server
npm downloads size
@hyper-fetch/axios
Runs every request through Axios
npm downloads size
@hyper-fetch/plugin-devtools
Connects your app to the HyperFlow devtools
npm downloads size
eslint-plugin-hyper-fetch
Lint rules for request and client generic types
npm downloads size
oxlint-plugin-hyper-fetch
The same rules on Oxlint, the Rust linter
npm downloads size

Silver sponsor banner

</a>

Silver sponsors

</a>

Examples

Fetching data

// Every value you get back is typed
const { data, error, status } = await getUsers.send();

Mutation with params and payload

// Params go in the URL and the payload goes in the body. Both are typed
const { data, error, status } = await createUser.send({
  params: { teamId: 1 },
  payload: { name: "Jane", email: "jane@example.com" },
});

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

Our sponsors

Sponsors

License

Apache-2.0

Frequently asked questions

Is hyper-fetch free to use?

hyper-fetch is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does hyper-fetch do?

⚡ Fetching and realtime data exchange framework.

What is hyper-fetch written in?

hyper-fetch is primarily written in TypeScript. Its source is publicly available at https://github.com/BetterTyped/hyper-fetch, and it has 1,344 GitHub stars.