Repolode
L-Blondy

L-Blondy/up-fetch

A TypeScript fetch client builder that adds schema validation, typed responses, retries, timeouts, and progress tracking on top of native fetch.

Stars
1,409
Forks
22
Open issues
2
Last commit
2 months ago

What is it?

upfetch is a fetch client builder that wraps the native fetch API. You create an instance with default options such as baseUrl, headers, timeout, and retry settings, then call it like fetch. Request params and bodies can be passed as plain objects, and JSON responses are parsed automatically.

The library accepts any schema that follows the Standard Schema specification, including zod, valibot, and arktype. When a schema is passed, the response is validated and returned with its inferred type, and a ResponseValidationError is raised on mismatch. Errors for non-ok responses are thrown as ResponseError by default, and both reject and parseRejected can be customized.

It also provides retries with configurable attempts, delay, and conditions, per-request timeouts, lifecycle hooks, and upload and download progress and streaming callbacks. The package is published on npm as up-fetch and runs in browsers, Node.js, Bun, Deno, Cloudflare Workers, and Vercel Edge Runtime.

Key features

  • 01Standard Schema validation with zod, valibot, arktype, and other compatible libraries
  • 02Plain objects for query params and request bodies, with automatic JSON serialization
  • 03Retries with configurable attempts, delay, and retry conditions
  • 04Per-request and default timeouts
  • 05Upload and download progress plus streaming callbacks
  • 06Lifecycle hooks for request, response, success, error, and retry

Use cases

  • Building a typed API client in a TypeScript frontend with runtime response validation
  • Adding retries and timeouts to calls against unreliable third-party APIs
  • Showing upload or download progress bars in a web app
  • Consuming streamed responses such as AI chat output

Quick start

  1. 1

    Install the package from npm

    npm i up-fetch
  2. 2

    Create an upfetch instance wrapping native fetch

  3. 3

    Make a request with optional schema validation

Things to know

  • Schema validation requires a separate library such as zod or valibot.

Topics

FAQ

What is up-fetch?
A TypeScript fetch client builder that adds schema validation, typed responses, retries, timeouts, and progress tracking on top of native fetch. upfetch is a fetch client builder that wraps the native fetch API. You create an instance with default options such as baseUrl, headers, timeout, and retry settings, then call it like fetch. Request params and bodies can be passed as plain objects, and JSON responses are parsed automatically.
Is up-fetch free to use? What license does it have?
up-fetch is open source under the MIT license. Check the license terms before using it in commercial products.
Is up-fetch still maintained?
Updated within 6 months. The last commit to up-fetch was on Sep 1, 2026.
What can I use up-fetch for?
Building a typed API client in a TypeScript frontend with runtime response validation Adding retries and timeouts to calls against unreliable third-party APIs Showing upload or download progress bars in a web app Consuming streamed responses such as AI chat output
How do I install up-fetch?
Install the package from npm: npm i up-fetch Create an upfetch instance wrapping native fetch Make a request with optional schema validation
Where can I get up-fetch?
The source code and installation instructions are on GitHub: https://github.com/L-Blondy/up-fetch

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects