Registry / devops / fetch-http2

fetch-http2

JSON →
library1.5.0jsnpmunverified

Native http2 fetch implementation for Node.js (v1.5.0). Provides a WHATWG fetch-compatible API that exclusively uses HTTP/2 connections. Requires Node >=16. Ships TypeScript types. Unlike node-fetch or undici, this library does not fall back to HTTP/1.1 — it assumes the server supports HTTP/2. Suitable for services that target HTTP/2-only endpoints. Release cadence: occasional minor/patch updates.

npm install fetch-http2
INSTALL
IMPORT
SIG · FETCH-HTTP2
F
fetch-http2
devopsjavascriptv1.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fetch
import { fetch } from 'fetch-http2'
import fetch from 'fetch-http2'
Named export only, not default.
fetch
const { fetch } = require('fetch-http2')
const fetch = require('fetch-http2')
CJS require with destructuring.
fetch
import { fetch } from 'fetch-http2'
import fetch from 'fetch-http2'
TypeScript: named import, not default.

Demonstrates basic fetch usage with the HTTP/2-only fetch implementation.

import { fetch } from 'fetch-http2'; import { Headers, Request, Response } from 'fetch-http2'; async function main() { const res = await fetch('https://httpbin.org/json'); const json = await res.json(); console.log(json); } main().catch(console.error);
Debug
Known issues
gotchaThis module does NOT fall back to HTTP/1.1. If the server does not support HTTP/2, the request will fail.
fix
Ensure target endpoints support HTTP/2, or use a fallback library like node-fetch or undici.
affects: >=1.0
gotchaRequires Node.js >=16. May not work on older Node versions.
fix
Upgrade Node.js to version 16 or higher.
affects: >=1.0
gotchaThe API does not support HTTP/1.1 proxies or custom agent configurations for HTTP/1.1.
fix
Use an HTTP/2-compatible proxy or configure directly.
affects: >=1.0
deprecatedNo known deprecations yet, but check for future breaking changes in the library's GitHub releases.
fix
Monitor releases.
affects: >=1.0
Errors
Common errors & fixes
TypeError: fetch is not a function
Default import instead of named import.
fix
Use `import { fetch } from 'fetch-http2'` or `const { fetch } = require('fetch-http2')`.
Error [ERR_HTTP2_INVALID_SESSION]: The session has been destroyed
The server does not support HTTP/2 or the connection was closed unexpectedly.
fix
Verify that the server advertises HTTP/2 support (via ALPN or direct knowledge).
TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string
Passing a non-string value to fetch, e.g., an object.
fix
Ensure the first argument to fetch is a string URL or a Request object.
Upgrade
Version history
1.5.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
fetch-http2 — npm install fetch-http2 · libregistry