What is HttpClient?

Avatar of Hemanta SundarayHemanta Sundaray

HttpClient is Effect’s module for sending HTTP requests and handling responses. It provides a consistent API that works across different JavaScript runtimes: Node.js, browsers, Bun, Deno, and others.

Different JavaScript runtimes have different ways of making HTTP requests. Node.js has http/https modules, browsers have the Fetch API, and other runtimes have their own implementations.

HttpClient abstracts over these differences. You write your HTTP code once using the HttpClient interface, and then provide a platform-specific implementation when you run it.

The effect package ships with FetchHttpClient, which uses the Fetch API available in modern Node.js (v18+) and all browsers.

This is why every example in this course provides a FetchHttpClient.layer:

Effect.provide(FetchHttpClient.layer);

You’re telling Effect: “When this code needs an HTTP client, use the Fetch-based implementation.”

Sign in to save progress

Stay in the loop

Get notified when new chapters are added and when this course is complete.