node-fetch
Node-fetch is a lightweight module that brings the browser's Fetch API to Node.js, providing a familiar and standards-compliant HTTP client. It implements the W…
Installation
npm install node-fetch
yarn add node-fetch
pnpm add node-fetch
Import
import fetch from 'node-fetch';
Quick Example
const response = await fetch('https://api.example.com/data');
const data = await response.json();
console.log(data);About node-fetch
Node-fetch is a lightweight module that brings the browser's Fetch API to Node.js, providing a familiar and standards-compliant HTTP client. It implements the WHATWG Fetch specification, including Request, Response, Headers, and Body classes, allowing developers to use the same HTTP API they use in browser code on the server. Node-fetch supports streaming responses, request and response body as Node.js Readable streams, gzip and deflate decompression, redirect following, timeout handling, and custom agents for connection pooling and proxy support. The library is intentionally minimal, focusing on spec compliance rather than adding convenience features like automatic retries or interceptors. Node-fetch v3 is an ESM-only module, while v2 supports CommonJS for backward compatibility. With Node.js 18+ including a built-in global fetch based on Undici, node-fetch is most relevant for older Node.js versions or projects that need the exact same Fetch API behavior across all environments. It remains one of the most depended-upon packages in the npm ecosystem.
Quick Facts
| Package | node-fetch |
| Category | HTTP |
| Weekly Downloads | 40M+ |
| License | MIT |
| Install | npm install node-fetch |
Related Packages
Axios is a promise-based HTTP client for the browser and Node.js that provides an elegant and powerf…
Got is a human-friendly and powerful HTTP request library for Node.js that provides an extensive fea…
Undici is a high-performance HTTP/1.1 client for Node.js, developed by the Node.js team and serving …
Ky is a tiny and elegant HTTP client based on the browser Fetch API, providing a more convenient API…
SuperAgent is a progressive HTTP request library for Node.js and the browser that provides a flexibl…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.