cross-fetch

Universal WHATWG Fetch API ponyfill for Node, browsers, and React Native

Library
npm
v4.1.0
1,696 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
43 /100 Fair
Development Activity 0
Maintenance 20
Community 52
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
70 /100 Good
Architecture 68
Code Quality 72
Innovation 55
Learning Curve 85

cross-fetch provides a single fetch implementation that behaves consistently across Node.js, browsers, and React Native, so libraries and applications can call the WHATWG Fetch API without branching on runtime environment. It resolves to node-fetch under Node, the browser’s native fetch in browsers, and a React Native-compatible implementation on that platform, all behind one import.

The package ships both as a ponyfill (cross-fetch, the default import — does not touch global state) and as a polyfill (cross-fetch/polyfill, which assigns fetch/Headers/Request/Response onto globalThis for code that expects fetch to already exist globally). It also normalizes schemaless URLs (//example.com/path) to https:// on the server for parity with browser behavior.

What You Get

  • A single fetch import that resolves to the correct implementation per environment (Node via node-fetch, browser native, React Native-specific build) via package.json’s browser/react-native/main fields
  • A ponyfill entry point (cross-fetch) that does not mutate global scope, for libraries that want an explicit import
  • A polyfill entry point (cross-fetch/polyfill) that assigns fetch/Headers/Request/Response onto the global object for code expecting ambient fetch
  • Schemaless URL normalization (//host/path -> https://host/path) on the Node side for browser-like behavior parity
  • Bundled TypeScript type definitions (index.d.ts)

Common Use Cases

  • Isomorphic/universal JavaScript libraries and SDKs that must run identically in Node and the browser without environment-specific fetch code
  • Server-side rendering (Next.js, Remix, etc.) codebases that share data-fetching logic between server and client bundles
  • Test suites and Node scripts that need a spec-compliant fetch before Node’s own native fetch was universally available
  • React Native apps that want the same fetch-based data layer code as their web counterpart

Under The Hood

Architecture - The package’s package.json routes to different entry files per consumer via the main (dist/node-ponyfill.js), browser (dist/browser-ponyfill.js), and react-native (dist/react-native-ponyfill.js) fields, letting bundlers and Node’s own resolution algorithm pick the right implementation automatically. The Node ponyfill (src/node-ponyfill.js) is a thin wrapper around node-fetch that additionally rewrites schemeless URLs to https:// before delegating, and re-exports Headers/Request/Response from the same underlying package. The separate polyfill/ subpackage and cross-fetch/polyfill entry point (src/node-polyfill.js) layer global assignment on top of the ponyfill only when global.fetch isn’t already defined, keeping the two usage modes cleanly separated.

Tech Stack - Plain JavaScript (CommonJS) with a single runtime dependency on node-fetch for the Node path; built with Rollup and esbuild plugins into per-target bundles, tested with Mocha/Chai (plus mocha-headless-chrome for real-browser test runs) and nock for HTTP mocking, with standard for linting.

Code Quality - Over 40 files under test/, organized by concern (test/fetch-api, test/module-system, test/setup), including a headless-Chrome run to validate actual browser behavior rather than only a jsdom approximation — a meaningfully more rigorous approach for a cross-environment compatibility shim. SECURITY.md documents a responsible-disclosure process, and Husky/commitlint enforce conventional commits, though the project’s own commit velocity has slowed since Node adopted native fetch.

API Design - The package deliberately mirrors the standard fetch(url, options) signature and Web-standard Headers/Request/Response classes exactly, so switching between cross-fetch and a native fetch requires no code changes — the entire value proposition is being invisible at the call site while resolving correctly per platform.

Used by 10 apps in this directory

TypeScript
96%
Other

Amplication

AI Code Assistants · Automation · Developer Tools

16,015

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
58
Repo Health
84
Technical
60
Dependency
Built with
TypeScript 96%
Updated 3 months ago
TypeScript
51%
MIT

Ghost

Blogging · CMS

55,450

Open source headless Node.js CMS for professional publishing, paid memberships, and newsletters with a fully owned audience.

View details
96
Repo Health
85
Technical
67
Dependency
Built with
TypeScript 51%
JavaScript 44%
Updated 4 days ago
TypeScript
71%
Other

highlight.io

Analytics · Developer Tools · Monitoring

9,378

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
67
Repo Health
78
Technical
65
Dependency
Built with
TypeScript 71%
Go 16%
Updated 1 months ago
TypeScript
62%
MIT

Jitsu

Data Engineering

5,094

Open-source, fully-scriptable data ingestion engine that streams events from web, apps, and APIs to any data warehouse in real time.

View details
88
Repo Health
79
Technical
66
Dependency
Built with
TypeScript 62%
Go 36%
Updated 1 weeks ago
Clojure
56%
Other

Metabase

Analytics

49,438

The open-source BI platform that lets anyone ask questions and build dashboards without writing SQL — with an embedded analytics SDK and AI-powered query assistant included.

View details
95
Repo Health
84
Technical
64
Dependency
Built with
Clojure 56%
TypeScript 38%
Updated 4 days ago
TypeScript
98%
Other

Novu

Developer Tools

40,084

Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.

View details
93
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 98%
Updated 5 days ago
TypeScript
96%
Apache 2.0

Pezzo

AI Development · Monitoring

3,275

Open-source LLMOps platform for prompt management, AI observability, intelligent caching, and real-time cost tracking across LLM providers.

View details
61
Repo Health
75
Technical
66
Dependency
Built with
TypeScript 96%
Updated 1 months ago
TypeScript
51%
Other

Phase Console

Devops · Security

924

End-to-end encrypted secrets management for engineering teams — from local dev to Kubernetes production.

View details
84
Repo Health
73
Technical
63
Dependency
Built with
TypeScript 51%
Python 48%
Updated 5 days ago
TypeScript
97%
Other

Sourcebot

AI Code Assistants · Developer Tools · Search

3,952

A self-hosted, AI-powered code search engine that indexes every repo across GitHub, GitLab, Bitbucket, Gitea, Gerrit, and Azure DevOps, so both engineers and coding agents can search, browse, and ask questions about your codebase from one place.

View details
85
Repo Health
83
Technical
62
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers