Skip to content
Effect Days 2026 Get your ticket

BunSocket

Bun platform socket entry point for Effect sockets.

This module re-exports the shared Node socket constructors for TCP clients, Unix domain socket clients, and adapters from existing Node Duplex streams. It also provides Bun WebSocket layers using globalThis.WebSocket, including a constructor layer and a Socket.Socket layer for a WebSocket URL.

2 exports Added in v4.0.0 Source

Layers

Creates a Socket.Socket layer for a WebSocket URL using Bun's global WebSocket constructor, honoring protocol, open-timeout, and high-water-mark options.

Signature

declare const layerWebSocket: (url: string | Effect<string>, options?: {
readonly highWaterMark?: number;
readonly openTimeout?: Duration.Input;
readonly protocols?: string | Array<string>;
}) => Layer.Layer<Socket.Socket, never, never>

Provides a Socket.WebSocketConstructor backed by Bun's global WebSocket implementation.

Signature

declare const layerWebSocketConstructor: Layer.Layer<Socket.WebSocketConstructor>