Crux
API Reference@use-crux/core

Runtime Bridge

API reference for @use-crux/core/runtime-bridge schemas and command-plane helpers.

import {
  BridgeCommandRequestSchema,
  BridgeCommandResultSchema,
  RuntimeBridgeMessageSchema,
  RuntimePeerHelloSchema,
  connectRuntimeBridge,
  executeRuntimeBridgeCommand,
  getRuntimeBridgeManifest,
} from "@use-crux/core/runtime-bridge";

The Runtime Bridge is the local-dev command plane between the @use-crux/local Go service and a live application runtime. It is used for inspectable resources and framework-specific local commands. It is not the execution trace transport; runtime traces use @use-crux/core/observability.

The stable runtime-peer command surface currently includes store.read for registered inspectable resources. Arbitrary runtime evaluation is intentionally not part of the bridge command contract.

Command errors

Failed commands return command.error with a stable error message and structured details. Runtime peers normalize thrown values with the same observability error contract used by spans, including thrown, summary, name, message, optional stack, safe raw data, phase, and errorKind when known.

The local Go bridge preserves those details for WebSocket and HTTP bridge commands, and emits command.failed events for failed dispatches.

Schemas

ExportDescription
RuntimeBridgeConfigSchemaRuntime bridge configuration accepted by Crux config/integrations.
RuntimeBridgeMessageSchemaUnion schema for bridge messages.
RuntimePeerHelloSchemaPeer handshake payload.
BridgeCommandRequestSchemaCommand request sent by the Go service to a runtime peer.
BridgeCommandResultSchemaSuccessful command response.
BridgeCommandErrorSchemaFailed command response.

Helpers

ExportDescription
getRuntimeBridgeManifest()Returns the runtime peer manifest exposed to the local service.
connectRuntimeBridge()Connects a long-lived runtime peer.
executeRuntimeBridgeCommand()Executes a typed bridge command against registered runtime resources.

On this page