Installation
Requirements
Rezo requires Node.js 22.0.0 or later. If you are targeting Bun, Deno, or a browser environment, the corresponding runtime version must support ES2022.
Package Managers
Install with your preferred package manager:
# npm
npm install rezo
# yarn
yarn add rezo
# pnpm
pnpm add rezo
# bun
bun add rezo Basic Import
The default import gives you a pre-configured instance with the Node.js HTTP adapter. You can use it immediately for requests:
import rezo from 'rezo';
const { data } = await rezo.get('https://api.example.com/users'); To import the class, error types, or utilities alongside the default instance:
import rezo, { Rezo, RezoError, RezoHeaders, CookieJar } from 'rezo'; Platform-Specific Imports
Rezo provides dedicated entry points for each runtime. These configure the correct adapter automatically and enable bundler-level tree-shaking.
// Node.js (also used by Bun)
import rezo from 'rezo/platform/node';
// Browser
import rezo from 'rezo/platform/browser';
// Bun (explicit)
import rezo from 'rezo/platform/bun';
// Deno
import rezo from 'rezo/platform/deno';
// Cloudflare Workers / Edge runtimes
import rezo from 'rezo/platform/worker';
// React Native
import rezo from 'rezo/platform/react-native'; When you import from the bare rezo specifier, bundlers resolve the correct platform entry automatically using the exports conditions in package.json (browser, react-native, bun, deno, import, require).
Adapter-Specific Imports
If you want full control over which adapter is bundled, import directly from the adapter entry point. This is useful for tree-shaking — only the adapter you import ends up in your bundle.
// Node.js HTTP/1.1 adapter (default)
import { Rezo } from 'rezo/adapters/http';
// Node.js HTTP/2 adapter
import { Rezo } from 'rezo/adapters/http2';
// Fetch API adapter (browsers, Deno, edge)
import { Rezo } from 'rezo/adapters/fetch';
// XMLHttpRequest adapter (legacy browsers)
import { Rezo } from 'rezo/adapters/xhr';
// cURL adapter (shell execution)
import { Rezo } from 'rezo/adapters/curl';
// React Native adapter
import { Rezo } from 'rezo/adapters/react-native'; Each adapter entry re-exports the Rezo class pre-wired with that adapter, so you can create instances without passing an adapter manually:
import { Rezo } from 'rezo/adapters/fetch';
const client = new Rezo({ baseURL: 'https://api.example.com' });
const { data } = await client.get('/users'); Sub-Package Imports
Rezo also exposes dedicated entry points for the crawler, DOM utilities, and wget functionality:
// Crawler
import { Crawler } from 'rezo/crawler';
// DOM parsing (linkedom-based)
import { parseHTML } from 'rezo/dom';
// Wget-style recursive downloader
import { wget } from 'rezo/wget'; ESM and CommonJS
Rezo is published as an ES module ("type": "module") with CommonJS fallbacks. Both module systems are fully supported.
ESM (recommended):
import rezo from 'rezo';
import { Rezo, RezoError } from 'rezo'; CommonJS:
const rezo = require('rezo').default;
const { Rezo, RezoError } = require('rezo'); All entry points (platform, adapter, crawler, etc.) provide both .js (ESM) and .cjs (CommonJS) variants via the exports map.
TypeScript Configuration
Rezo is written in TypeScript and ships with complete type definitions. No @types package is needed.
For the best experience, ensure your tsconfig.json includes:
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"esModuleInterop": true,
"strict": true
}
} The "moduleResolution": "bundler" setting (or "node16" / "nodenext") is required for the exports map to resolve correctly. If you are on "moduleResolution": "node", the typesVersions field provides fallback resolution.
Key Type Exports
import type {
RezoResponse,
RezoRequestConfig,
RezoDefaultOptions,
RezoStreamResponse,
RezoDownloadResponse,
RezoUploadResponse,
HttpMethod,
ResponseType
} from 'rezo'; All response types are generic. RezoResponse<T> lets you type the data property:
interface User {
id: number;
name: string;
email: string;
}
const { data } = await rezo.get<User[]>('https://api.example.com/users');
// data is typed as User[] Verifying the Installation
Run a quick test to confirm everything is wired up:
import rezo, { VERSION } from 'rezo';
console.log(`Rezo v${VERSION}`);
const { status, data } = await rezo.get('https://httpbin.org/get');
console.log(status); // 200
console.log(data.url); // https://httpbin.org/get Next Steps
- Quick Start — Make requests, handle errors, and explore streaming