Appearance
Transports
A transport implements ITransportAdapter — subscribe, publish, plus optional extensions (invoke, getWireTopicInfo, etc.). The SDK ships three: an in-process broker for tests and demos, a Node-side NATS adapter for runners and headless tools, and a browser-side NATS adapter that opens a WebSocket and refreshes JWTs.
Pages in this section
| Page | What you'll learn |
|---|---|
| In-memory transport | InMemoryBroker + InMemoryTransport — how the in-process bus works, queueing, latency injection. |
| NATS transport | NatsTransport — root-prefix grammar, validation, JSON encoding, the INatsLikeConnection adapter. |
| Browser transport | createBrowserNatsTransport — WebSocket connect, JWT refresh, token/user-pass fallbacks. |
| Transport testing | Stubbing transports for actor unit tests, real-NATS harness for integration tests. |
Picking a transport
| Situation | Use |
|---|---|
| Unit test, single-process actor system | InMemoryTransport (with InMemoryBroker). |
| Production Node-side runtime, supervised by Host Service | NatsTransport over the bundled NATS sibling (the runner wires it for you). |
| Browser tab connected to a Host's NATS | createBrowserNatsTransport over /nats-ws. |
| Federation: actor invokes across roots | FederationTransportAdapter wrapping the underlying transport. |
You almost never construct a transport by hand in production code. The runner (Host Service) constructs the right transport and passes it into MatrixRuntime. You construct transports yourself in tests.
Wire format, briefly
All three transports carry MxEnvelope JSON:
json
{ "op": "market.quote", "payload": { "symbol": "TSLA" }, "from": "<sender>", "lamport": 42 }InMemoryTransport passes the object reference directly — no serialization. NatsTransport encodes/decodes via TextEncoder/TextDecoder + JSON.stringify/JSON.parse. The browser variant uses the same NATS adapter under the hood with a WebSocket connection.
Subject prefixing
NATS-backed transports prepend an authority root to every subject:
<root>.<mount>.$inbox ← inbox
<root>.<mount>.$events ← events
<root>.$reply.<corrId> ← replyThe root is a DNS-style identifier like COM.NIMBLETEC.RICHARD-SANTOMAURO. InMemoryTransport does not prefix — its topicPrefix is the empty string.
getWireTopicInfo(topic) (ITransportAdapter extension) lets a caller inspect what wire subject a logical topic resolves to. Useful for debugging.
Source:
projects/matrix-3/packages/core/src/engine/messaging/TopicRouter.ts(subject grammar),projects/matrix-3/packages/core/src/transport/{InMemoryTransport,NatsTransport,createBrowserNatsTransport}.ts(each adapter).