A lightweight fetch ponyfill that only provides a fetch polyfill in Node.js environments. In browsers, it uses the native fetch API without modification. This approach avoids unnecessary polyfilling in browsers and ensures minimal overhead. Version 1.0.3 is the latest stable release. The package is updated infrequently, with a simple API that exports a single fetch function. It differentiates itself from other cross-platform fetch libraries by being a true ponyfill (no side effects or global pollution) and only targeting Node.js for polyfilling.
npm install cross-fetch-ponyfillNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage: importing fetch as default and making a GET request with async/await.
Import the fetch function and use it directly. Do not expect global.fetch to be available.
Consider alternatives like 'node-fetch' (for Node 18+ native fetch is stable) or native fetch in modern browsers.
Set 'moduleResolution' to 'node' or 'node16' in tsconfig.json.
Install @types/cross-fetch-ponyfill (if available) or declare the module: declare module 'cross-fetch-ponyfill';
Use import fetch from 'cross-fetch-ponyfill' (default import) instead of import { fetch } from 'cross-fetch-ponyfill'.