A universal WHATWG Fetch API implementation that works across Node.js, browsers, and React Native.
cross-fetch is a universal implementation of the WHATWG Fetch API that works consistently across Node.js, browsers, React Native, and worker environments. It solves the problem of writing platform-specific HTTP request code by providing a single, standardized interface that behaves identically wherever JavaScript runs.
JavaScript developers building applications that need to run across multiple environments (Node.js, browsers, React Native, workers) and want consistent HTTP request handling without platform-specific code.
Developers choose cross-fetch because it provides a simple, zero-configuration way to use the standard Fetch API everywhere, with the flexibility to use it as either a polyfill or ponyfill based on their risk tolerance and architectural preferences.
Universal WHATWG Fetch API for Node, Browsers and React Native.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Works identically on Node.js, browsers, React Native, and workers by proxying to environment-specific implementations like node-fetch and whatwg-fetch, as stated in the README's 'How does cross-fetch work?' section.
Offers flexibility to use as a polyfill (global) or ponyfill (local import), allowing developers to avoid global namespace pollution if desired, highlighted in the install and usage examples.
No setup or instantiation required—just import and use the fetch function directly, making it easy to integrate, as demonstrated in the usage code snippets.
Adheres to the WHATWG Fetch API specification, ensuring consistent behavior across all supported environments, which is a core philosophy mentioned in the README.
Relies on underlying libraries like node-fetch and whatwg-fetch, so bugs or breaking changes in those dependencies can affect cross-fetch without direct control, as noted in the proxy mechanism explanation.
Only provides basic fetch functionality; lacks built-in support for common needs like request timeouts, progress tracking, or automatic retries, requiring additional code or libraries for complex use cases.
Using polyfill mode introduces risk if the Fetch spec evolves, potentially causing debugging issues, and adds unnecessary bundle size in environments where fetch is already native, as warned in the FAQ.