Advanced

Platform Entries

Rezo provides six platform-specific entry points, each preconfigured with the optimal HTTP adapter for that runtime. Instead of auto-detecting your environment at import time, you pick the right entry point and get a client that is tuned for your platform with no unnecessary code.

Available Platforms

PlatformImport PathAdapterBest For
Node.jsrezo/platform/nodeHTTP (native http/https)Server applications, CLIs, scripts
Bunrezo/platform/bunHTTP (Bun’s Node.js compat)Bun server applications
Denorezo/platform/denoHTTP (Deno’s Node.js compat)Deno server applications
Browserrezo/platform/browserFetch (native fetch)SPAs, web applications
React Nativerezo/platform/react-nativeReact Native adapterMobile applications
Workerrezo/platform/workerFetch (native fetch)Edge functions, Cloudflare Workers

Node.js

The Node.js entry uses the native HTTP adapter, which provides the most features:

import rezo, { Rezo, RezoError } from 'rezo/platform/node';

// Default instance (ready to use)
const { data } = await rezo.get('https://api.example.com/users');

// Custom instance
const client = new Rezo({
  baseURL: 'https://api.example.com',
  timeout: 5000,
});

const users = await client.getJson('/users');

Node.js Adapter Features

  • Cookie jar integration with automatic persistence
  • Proxy support (HTTP, HTTPS, SOCKS4, SOCKS5)
  • Streaming responses with backpressure handling
  • Compression (gzip, deflate, brotli, zstd)
  • Upload/download progress tracking
  • TLS/SSL configuration and certificate pinning
  • Socket telemetry and connection reuse
  • HTTP/2 support (via separate rezo/adapters/http2 import)

Bun

The Bun entry also uses the HTTP adapter, leveraging Bun’s Node.js compatibility layer:

import rezo, { Rezo, RezoError } from 'rezo/platform/bun';

const { data } = await rezo.get('https://api.example.com/users');

const client = new Rezo({
  baseURL: 'https://api.example.com',
  timeout: 5000,
});

Bun Advantages

  • Full Node.js http/https support
  • BoringSSL backend produces Chrome-like TLS fingerprints (great for stealth)
  • Cookie jar integration
  • Proxy support
  • Streaming and compression

Deno

The Deno entry uses the HTTP adapter via Deno’s Node.js compatibility:

import rezo, { Rezo, RezoError } from 'rezo/platform/deno';

const { data } = await rezo.get('https://api.example.com/users');

Note: Deno requires --allow-net permission for network access.

Deno Features

  • Cookie jar integration
  • Proxy support (HTTP/HTTPS/SOCKS)
  • Streaming responses
  • Compression (gzip, deflate, brotli, zstd)
  • Upload/download progress

Browser

The browser entry uses the Fetch adapter for minimal bundle size:

import rezo, { Rezo, RezoError } from 'rezo/platform/browser';

const { data } = await rezo.get('https://api.example.com/users');

const client = new Rezo({
  baseURL: 'https://api.example.com',
  timeout: 5000,
});

Browser Adapter Features

  • Native fetch API with modern browser support
  • AbortController timeout support
  • Automatic content-type handling
  • CORS support
  • Minimal bundle size (no Node.js APIs)

React Native

The React Native entry uses a dedicated adapter optimized for mobile:

import rezo, { Rezo, RezoError } from 'rezo/platform/react-native';

const { data } = await rezo.get('https://api.example.com/users');

const client = new Rezo({
  baseURL: 'https://api.example.com',
  timeout: 5000,
});

React Native Adapter Features

  • Optimized for React Native environment
  • Manual cookie header handling (no native jar in RN)
  • react-native-fs download support (optional)
  • Platform-specific guards (iOS/Android)
  • FormData and file upload support

Worker (Edge)

The worker entry uses the Fetch adapter for edge runtimes:

import rezo, { Rezo, RezoError } from 'rezo/platform/worker';

export default {
  async fetch(request: Request): Promise<Response> {
    const { data } = await rezo.get('https://api.example.com/data');
    return new Response(JSON.stringify(data));
  },
};

Edge Runtime Features

  • Native fetch API (edge-compatible)
  • AbortController timeout support
  • Automatic content-type handling
  • No Node.js APIs required
  • Minimal cold start overhead

Compatible with: Cloudflare Workers, Vercel Edge Functions, Deno Deploy, Netlify Edge Functions.

What Each Entry Exports

Every platform entry exports the same set of symbols:

// Default export: pre-configured instance
export default rezo;

// Classes
export { Rezo, RezoError, RezoErrorCode };
export { RezoHeaders, RezoFormData, RezoCookieJar, Cookie };
export { createDefaultHooks, mergeHooks };

// Utilities
export { isRezoError, isCancel, Cancel, CancelToken, all, spread };

// Version
export { VERSION };

// Types
export type {
  RezoInstance, RezoResponse, RezoDefaultOptions,
  RezoRequestConfig, RezoConfig, HttpMethod,
  ResponseType, RezoHooks, CacheOption,
};

How to Choose

Your RuntimeRecommended Import
Node.js serverrezo/platform/node
Bun serverrezo/platform/bun
Deno serverrezo/platform/deno
React/Vue/Angular SPArezo/platform/browser
React Native mobile apprezo/platform/react-native
Cloudflare Workerrezo/platform/worker
Vercel Edge Functionrezo/platform/worker
Deno Deployrezo/platform/worker or rezo/platform/deno
Universal/isomorphicUse the default rezo import (auto-detects)

Default Import vs Platform Import

The default import rezo from 'rezo' uses the HTTP adapter and assumes a Node.js environment. For other runtimes, use the platform-specific import:

// Default - assumes Node.js
import rezo from 'rezo';

// Explicit platform - guaranteed correct adapter
import rezo from 'rezo/platform/browser';

The platform imports are preferred because:

  1. They are explicit about which adapter is used
  2. They enable better tree-shaking (bundlers can exclude unused adapters)
  3. They avoid runtime environment detection overhead
  4. They work correctly in edge cases where auto-detection fails