effect-rpc
    Preparing search index...

    Function createEffectRPC

    • Creates an RPC backend layer using HTTP protocol.

      This function constructs a layered RPC client configured to communicate with a remote endpoint over HTTP. It uses the Fetch API for HTTP requests and NDJSON for request/response serialization by default, but you can use a custom serialization layer from RpcSerialization.

      NOTE: Make sure that, if you use a custom serialization layer, it is compatible with the RPC server you are communicating with. This means, you most likely want to modify the getServerLayers function invocation to use the same serialization layer!

      Parameters

      • config: { endpoint?: string; serialization?: SerializationLayer; url: string }

        Configuration object for the RPC backend.

        • Optionalendpoint?: string

          (Optional) The specific endpoint path to append to the base URL.

        • Optionalserialization?: SerializationLayer

          (Optional) Custom serialization layer to use for RPC communication of type SerializationLayer.

        • url: string

          The base URL of the RPC server.

      Returns Layer<Protocol, never, never>

      A Layer instance that provides the configured RPC client.

      • The default returned layer is composed with:
        • FetchHttpClient.layer for HTTP transport using the Fetch API.
        • RpcSerialization.layerNdjson for NDJSON serialization.
      • The endpoint is appended to the base URL if provided.
      const backend = createEffectRPC({ url: "https://api.example.com", endpoint: "/rpc" });
      
      // With a custom serialization layer
      import { RpcSerialization } from "@effect/rpc";
      const backend = createEffectRPC({
      url: "https://api.example.com",
      endpoint: "/rpc",
      serialization: RpcSerialization.layerJson,
      });

      0.5.0