Stop polyfilling fetch in your npm package

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • tl;dr: Let your users handle it. See https://github.com/BuilderIO/this-package-uses-fetch/

  • builder

    Drag and drop headless CMS for React, Vue, Svelte, Qwik, and more

  • I’ve maintained a handful of JavaScript SDKs over the years. And for each one, the question of how exactly to provide support for fetch in a Node environment inevitably comes up. In fact, we just recently had to resolve some issues concerning this in our Builder.io SDKs.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • axios

    Promise based HTTP client for the browser and node.js

  • You’re putting together an npm library that involves fetching data. There are many popular packages that can help you (axios, superagent, etc.) but in the spirit of not shipping bulky/redundant JS code to the browser, and the progress which browsers and JavaScript has made over the years, you try to use the platform whenever possible.

  • superagent

    Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.

  • You’re putting together an npm library that involves fetching data. There are many popular packages that can help you (axios, superagent, etc.) but in the spirit of not shipping bulky/redundant JS code to the browser, and the progress which browsers and JavaScript has made over the years, you try to use the platform whenever possible.

  • window.fetch polyfill

    A window.fetch JavaScript polyfill.

  • In this case, Github offers a great fetch polyfill for browsers: https://github.com/github/fetch

  • node-fetch

    A light-weight module that brings the Fetch API to Node.js

  • So for all versions of Node.js ≤17, you’ll need a Node fetch polyfill, the most popular of which is node-fetch: https://github.com/node-fetch/node-fetch

  • bun

    Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one

  • Bun: support Fetch out-of-the-box

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • wrangler-legacy

    Discontinued 🤠 Home to Wrangler v1 (deprecated)

  • Cloudflare Workers: supports Fetch out-of-the-box

  • isomorphic-fetch

    Isomorphic WHATWG Fetch API, for Node & Browserify

  • You can get around some of the above issues using a library called isomorphic-fetch, but not all of them. It also hasn’t been updated since 2015, and is locked on v2.x of node-fetch (whereas v3 has been out for some time now)

  • deno

    A modern runtime for JavaScript and TypeScript.

  • Deno: supports Fetch out-of-the-box

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts