🌐
HTTP40M+/wkMIT

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
npm install node-fetch
yarn
yarn add node-fetch
pnpm
pnpm add node-fetch

Import

ESM
import fetch from 'node-fetch';

Quick Example

usage
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

Packagenode-fetch
CategoryHTTP
Weekly Downloads40M+
LicenseMIT
Installnpm install node-fetch

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.