Registry / devops / axios-http2-adapter

axios-http2-adapter

JSON →
library1.0.3jsnpmunverified

Custom Axios adapter that enables HTTP/2 support using http2-wrapper. Current stable version 1.0.3, released regularly. Key differentiator: fills the gap until Axios natively supports HTTP/2, offering seamless integration with existing Axios codebases. Unlike alternatives, it requires only peer dependency axios ^1.9 and optionally http2-wrapper for configuration.

npm install axios-http2-adapter
INSTALL
IMPORT
SIG · AXIOS-HTTP2-ADAPTE
A
axios-http2-adapter
devopsjavascriptv1.0.3
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.

createHTTP2Adapter
import { createHTTP2Adapter } from 'axios-http2-adapter'
const createHTTP2Adapter = require('axios-http2-adapter').createHTTP2Adapter
ESM and CJS both supported; named export
default
import axiosHTTP2Adapter from 'axios-http2-adapter'
const axiosHTTP2Adapter = require('axios-http2-adapter')
Default export equals the createHTTP2Adapter function
type HTTP2AdapterConfig
import type { HTTP2AdapterConfig } from 'axios-http2-adapter'
TypeScript only; no import in JS

Shows basic setup: import and create adapter, assign to axios defaults, then use axios as usual with HTTP/2 support.

import axios from 'axios'; import { createHTTP2Adapter } from 'axios-http2-adapter'; const adapter = createHTTP2Adapter(); axios.defaults.adapter = adapter; axios.get('https://example.com') .then(response => console.log(response.status)) .catch(error => console.error(error));
Debug
Known issues
gotchaRequires Node.js with HTTP/2 support (Node >= 8.4) and the http2-wrapper peer dependency. If http2-wrapper not installed, adapter will silently fallback? Actually it throws.
fix
Ensure http2-wrapper is installed (npm install http2-wrapper) or configure agent explicitly.
affects: >=1.0.0
breakingVersion 1.0.3 changed default export behavior? No, consistent from initial.
affects: >=1.0.0
deprecatedAdapter might be abandoned if axios ever implements native HTTP/2.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'http2-wrapper'
Missing peer dependency http2-wrapper.
fix
Run npm install http2-wrapper
TypeError: adapter is not a function
Incorrect import or usage of createHTTP2Adapter.
fix
Use createHTTP2Adapter() to create adapter, not the module itself.
Error [ERR_HTTP2_ERROR]: Connection closed with error code 6
Server does not support HTTP/2 or ALPN negotiation failed.
fix
Set force: true in adapter config to skip ALPN check.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
axiosrequiredpeer dependency, core requirement
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
axios-http2-adapter — npm install axios-http2-adapter · libregistry