@hyperttp/core
v1.5.6
Published
High-performance, extensible HTTP client for Node.js, Bun, Deno and Browser
Maintainers
Readme
@hyperttp/core ⚡
High-performance HTTP engine for Node.js and Bun.
English | Русский
What is @hyperttp/core?
@hyperttp/core is a low-level, high-performance HTTP engine designed for building fast, extensible HTTP clients and SDKs.
It provides:
- ⚡ Optimized request execution pipeline
- 🔀 Runtime-aware transport abstraction
- 🔌 Plugin lifecycle hooks
- 🛡️ Safe request/response handling
- 📦 Zero runtime dependencies
@hyperttp/core is the foundation that powers hyperttp,
but it can also be used directly to build custom HTTP clients, SDKs, API wrappers and internal tooling.
💡 Looking for a batteries-included client?
Use
hyperttp— it ships with retries, caching, parsing, rate limiting and other plugins already configured.
Why @hyperttp/core?
Unlike the native fetch(), HyperCore is designed as an extensible HTTP engine rather than just a request API.
| Feature | fetch | @hyperttp/core | | ---------------------- | :---: | :------------: | | Transport abstraction | ❌ | ✅ | | Plugin pipeline | ❌ | ✅ | | Request/Response hooks | ❌ | ✅ | | Custom transports | ❌ | ✅ | | Built for SDKs | ⚠️ | ✅ | | Safe response cleanup | ❌ | ✅ | | Runtime auto-detection | ❌ | ✅ |
Features
- ⚡ Optimized hot paths with minimal allocations
- 🚀 Fast manual query string serialization
- 🔀 Automatic runtime transport selection
- 🔌 Extensible plugin system
- 🧠 Request/response lifecycle hooks
- 🛡️ Protection against Prototype Pollution
- 🛡️ CRLF header validation
- 🛡️ Safe
ArrayBufferhandling - 📦 Zero runtime dependencies
- 🌊 Native stream support
- 🧹 Automatic resource cleanup
- 📈 Designed for high concurrency
Architecture
hyperttp
│
▼
@hyperttp/core
│
┌───────────────┴───────────────┐
│ │
▼ ▼
Transport Layer Plugin Pipeline
│ │
├── BunTransport │
├── UndiciTransport ├── Retry
├── NodeTransport ├── Cache
├── BrowserTransport ├── Parser
└── Custom Transport └── Пользовательские плагиныInstallation
npm install @hyperttp/coreRecommended transports:
# Bun
npm install @hyperttp/transport-bun
# Node.js
npm install @hyperttp/transport-undiciQuick Start
import { HyperCore } from "@hyperttp/core";
const http = new HyperCore({
network: {
baseURL: "https://api.example.com",
headers: {
"X-App-Version": "1.0.0",
},
},
});
const response = await http.get("/users", {
query: {
page: 1,
limit: 20,
},
});
const users = await response.json();
console.log(users);Error Handling
import { HyperCore, HttpClientError, TimeoutError } from "@hyperttp/core";
try {
const res = await http.get("/users");
console.log(await res.json());
} catch (error) {
if (TimeoutError.isTimeoutError(error)) {
console.error("Request timed out.");
}
if (HttpClientError.isHttpClientError(error)) {
console.error(error.statusCode, error.message);
}
throw error;
}Streaming
Read a streaming response:
const response = await http.stream("https://stream.example.com/audio");
const reader = response.body.getReader();
while (true) {
const { done, value } = await reader.read();
if (done) break;
console.log(value.length);
}Discard a response body without buffering:
await http.dump("https://api.example.com/ping");Plugins
HyperCore exposes request lifecycle hooks that allow intercepting requests, responses and errors.
http.use({
name: "logger",
priority: 10,
onRequest(req) {
req.meta.start = performance.now();
},
onResponse(res, req) {
const elapsed = performance.now() - (req.meta.start as number);
console.log(`${req.method} ${req.url} -> ${res.status} (${elapsed.toFixed(2)} ms)`);
},
onError(error, req) {
console.error(`${req.url}: ${error.message}`);
},
});Transports
HyperCore automatically detects the current runtime, or you can provide your own transport.
| Transport | Runtime | | ---------------- | ------------- | | BunTransport | Bun | | UndiciTransport | Node.js | | NodeTransport | Bun / Node.js | | BrowserTransport | Browser | | Custom Transport | Any |
Example:
import { HyperCore } from "@hyperttp/core";
import { UndiciTransport } from "@hyperttp/transport-undici";
const http = new HyperCore({
customTransport: new UndiciTransport(),
});Performance
HyperCore is optimized for sustained high concurrency.
Recent stress testing:
- 200,000 requests
- 1000 concurrent connections
- 120 seconds
- 0 request errors
Optimizations include:
- minimal allocations
- object reuse
- optimized semaphore
- manual query serialization
- efficient header normalization
- zero-dependency core
Ecosystem
| Package | Description |
| ---------------------------- | ------------------------ |
| hyperttp | Ready-to-use HTTP client |
| @hyperttp/core | HTTP engine |
| @hyperttp/parser | Response parsing |
| @hyperttp/cache | Cache utilities |
| @hyperttp/transport-undici | Undici transport |
| @hyperttp/transport-bun | Bun transport |
Development
bun install
bun run lint
bun run typecheck
bun run test
bun run buildLicense
MIT
