whatisgithub

What is unfetch?

developit/unfetch — explained in plain English

Analysis updated 2026-06-26

5,718JavaScriptAudience · developerComplexity · 1/5Setup · easy

In one sentence

A tiny 500-byte JavaScript library that gives older browsers the modern fetch() API for making web requests, usable as a silent drop-in polyfill or an explicit import.

Mindmap

mindmap
  root((repo))
    What it does
      fetch polyfill
      Browser compat
      500 bytes
    Usage modes
      Global polyfill
      Explicit ponyfill
    Features
      GET and POST
      Custom headers
      Cookie support
    Limitations
      No streaming
      Manual error check
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add fetch() support to older browsers so existing code works without any changes.

USE CASE 2

Import unfetch explicitly to make HTTP requests that work across all browsers including IE.

USE CASE 3

Use a CDN script tag to drop fetch support into a plain HTML page with no build step.

What is it built with?

JavaScriptnpm

How does it compare?

developit/unfetchdylang/shortidimagemin/imagemin
Stars5,7185,7175,717
LanguageJavaScriptJavaScriptJavaScript
Setup difficultyeasyeasyeasy
Complexity1/51/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

So what is it?

Unfetch is a very small JavaScript library, roughly 500 bytes when compressed, that adds the ability to make web requests in older browsers that do not support the modern fetch() function. When a web page needs to load data from a server without refreshing the whole page, it typically calls fetch(). Unfetch provides that same calling style for browsers that would otherwise throw an error. The library can be used in two ways. The first is as a polyfill, meaning it quietly replaces the missing fetch() function in the browser so that existing code just works without any changes. The second is as a ponyfill, meaning you import it explicitly in your code and call it directly, without touching any global browser state. The ponyfill approach is useful when you want to be explicit about which function you are calling regardless of what the browser provides. Unfetch covers the basics: sending GET and POST requests, passing custom headers, including cookies via the credentials option, and reading the response as text, JSON, or a binary blob. It does not support streaming responses, and its Headers and Response objects are simplified versions of the full specification. The README is explicit about what is missing so developers know what they are getting. Two important behaviors differ from what some developers expect coming from older libraries like jQuery. By default, unfetch does not send or receive cookies unless you pass credentials: 'include'. Also, a failed HTTP status like a 404 or 500 does not cause the returned Promise to reject automatically. The promise only rejects on a network-level failure. Developers who want HTTP errors to behave as errors need to check response.ok themselves and throw accordingly. The package is published to npm and can also be dropped into a page directly from a CDN link. For use in Node.js rather than a browser, a companion package called isomorphic-unfetch is available from the same author.

Copy-paste prompts

Prompt 1
Using unfetch as a polyfill in my web project, show me how to set it up so IE11 can call fetch(), and demonstrate a POST request with a JSON body that correctly handles 404 errors by checking response.ok.
Prompt 2
I want to use unfetch as a ponyfill, imported directly, not patching any globals. Show me how to import it in a module and make a GET request that parses a JSON response and throws on HTTP errors.
Prompt 3
My app uses unfetch and needs to send cookies with a cross-origin request. Write the fetch call with the correct credentials option and explain how this differs from the default behavior.
Prompt 4
Show me a side-by-side comparison of the same API request written with XMLHttpRequest versus unfetch, including error handling for both network failures and non-200 status codes.

Frequently asked questions

What is unfetch?

A tiny 500-byte JavaScript library that gives older browsers the modern fetch() API for making web requests, usable as a silent drop-in polyfill or an explicit import.

What language is unfetch written in?

Mainly JavaScript. The stack also includes JavaScript, npm.

How hard is unfetch to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is unfetch for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.