Getting Started

Installation

Requirements

Core Rezo — every adapter (HTTP, HTTP/2, Fetch, XHR, cURL, React Native), the cookie jar, the proxy manager, the queue, stealth, hooks, interceptors — runs on Node.js 18 or later.

The optional Crawler module (rezo/crawler) needs Node.js 22 or later. Its on-disk URL store and response cache are backed by Node’s built-in node:sqlite driver, which landed in Node 22. That keeps the crawler free of native build dependencies.

For Bun, Deno, browsers, and edge runtimes, the version requirement is just “supports ES2022,” which every current release does.

What you importMinimum runtime
rezo, rezo/platform/*, rezo/adapters/*, rezo/stealth, rezo/wget, rezo/domNode.js 18+ / Bun / Deno / modern browsers / edge
rezo/crawlerNode.js 22+ (or Deno with node:sqlite enabled)

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 larger subsystems:

// Crawler
import { Crawler, CrawlerOptions } from 'rezo/crawler';

// DOM parsing (linkedom-based)
import { parseHTML } from 'rezo/dom';

// Wget-style recursive downloader — the Wget class for the full fluent
// API + event hooks, or the wget() function for one-shot downloads.
import { Wget, wget } from 'rezo/wget';

// Stealth (browser fingerprint emulation)
import { RezoStealth, listProfiles } from 'rezo/stealth';

// Adapter picker utilities (advanced)
import { detectRuntime, getAdapterDiagnostics } from 'rezo/adapters';

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. VERSION and PACKAGE_NAME are exported from the main entry, so you don’t have to read package.json or hard-code the name anywhere:

import rezo, { VERSION, PACKAGE_NAME } from 'rezo';

console.log(`${PACKAGE_NAME} v${VERSION}`);

const { status, data } = await rezo.get('https://httpbin.org/get');
console.log(status); // 200
console.log(data.url); // https://httpbin.org/get

When you run the snippet above on the latest published version, it prints rezo v1.0.134 (queried live from the npm registry).

Next Steps

  • Quick Start — Make requests, handle errors, and explore streaming