Skip to content
Strata is pre-1.0. APIs, protocol, and storage format may change.

strata_component

strata_component packages collaborative state and behavior behind a typed, headless contract. It targets Erlang and JavaScript.

Use a component definition to package:

  • a stable component kind and version;
  • typed config encoding and decoding;
  • initial document creation;
  • local messages and typed outputs;
  • replicated Strata event handling; and
  • ownership of a root document and its descendants.

The host owns the shared strata_client.Connection, transport, authentication, presence, lifecycle, event routing, and UI adapters. Local updates can emit outputs. Replicated events cannot emit outputs. This rule prevents another client from repeating the originating action.

The strata_component module provides:

  • Definition(root, context, config, model, message, output);
  • definition for validated component construction;
  • kind, version, encode_config, and decode_config;
  • initial_document, init, update, and receive;
  • owned_document_ids;
  • Status, ComponentError, Init, Update, and Receive.

The strata_component/port module provides:

  • OutputPort(output, payload);
  • InputPort(message, input);
  • Binding(output, message, payload, input, config);
  • output_port, input_port, binding, and route;
  • config and metadata accessors;
  • PortError.

An output port selects a payload from a component output. An input port converts an input value into a component message. A binding maps between the two payload types with codec-backed configuration. The Gleam compiler checks the source output, mapping, target input, and component message types.

The package does not include runtime component discovery, a type-erased binding catalog, or a persisted connection graph.

Read Components and Bindings for host and routing guidance. Read the generated API reference for every public type and function.

Source: packages/strata_component.