A WHATWG-compliant Headers implementation for Node.js, version 3.0.1. It provides the standard Headers class as defined in the Fetch spec, with full support for immutable headers via the 'bag' symbol. Unlike other polyfills, this library is tested against the Web Platform Tests (WPT) and correctly handles Set-Cookie headers (iterates individually but joins all other duplicate headers with commas). It is actively maintained, ESM-only, and ships TypeScript declarations. Release cadence is irregular; latest stable is 3.0.1 as of late 2023.
npm install fetch-headersNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating Headers, appending values, iterating, and making headers immutable using the bag symbol.
Use dynamic import: const { Headers } = await import('fetch-headers')Use iteration to get individual Set-Cookie headers: for (const [name, value] of headers) { if (name === 'set-cookie') { /* handle each */ } }Only use bag.get(headers) for standard guard setting; avoid modifying other internal properties.
Use import statement or dynamic import: const { Headers } = await import('fetch-headers')Ensure you are using import { Headers } from 'fetch-headers' correctly.Import bag correctly: import { Headers, bag } from 'fetch-headers'; then bag.get(headers).guard = 'immutable'No dependency data recorded yet.