# Transport API URL: /docs/api/transport Transport API [#transport-api] Use the transport API when configuring how the runtime client communicates with worker processes. The transport abstracts MessagePort-based RPC over the worker boundary. Types [#types] void", "simplifiedType": "function", "required": true, "deprecated": false }, { "name": "onMessage", "description": "Register a handler for incoming kernel responses.", "tags": [ { "name": "param", "text": "handler - Callback invoked for each response from the worker" } ], "type": "(handler: (message: RuntimeResponse) => void) => void", "simplifiedType": "function", "required": true, "deprecated": false }, { "name": "close", "description": "Close the transport and release resources.", "tags": [], "type": "() => void", "simplifiedType": "function", "required": true, "deprecated": false } ] }} /> createWorkerTransport [#createworkertransport] `createWorkerTransport(workerUrl)` creates a `RuntimeTransport` that spawns a Web Worker from the given URL and establishes a MessageChannel for bidirectional communication. Returns `RuntimeTransport & { worker: Worker }`. createInProcessTransport [#createinprocesstransport] `createInProcessTransport()` creates a `RuntimeTransport` that runs the kernel in the same process using a MessageChannel. No Web Worker is spawned. Use this for testing or Node.js environments where worker isolation is not needed. Usage [#usage] Web Worker Transport (Default) [#web-worker-transport-default] ```typescript import { createRuntimeClient, fromMemoryFS } from '@taucad/runtime'; import { replicad } from '@taucad/runtime/kernels'; import { esbuild } from '@taucad/runtime/bundler'; import { createWorkerTransport } from '@taucad/runtime/transport'; const transport = createWorkerTransport(new URL('@taucad/runtime/worker', import.meta.url).href); const client = createRuntimeClient({ kernels: [replicad()], bundlers: [esbuild()], fileSystem: fromMemoryFS(), transport, }); ``` In-Process Transport (Testing) [#in-process-transport-testing] ```typescript import { createRuntimeClient, fromMemoryFS } from '@taucad/runtime'; import { replicad } from '@taucad/runtime/kernels'; import { esbuild } from '@taucad/runtime/bundler'; import { createInProcessTransport } from '@taucad/runtime/transport'; const client = createRuntimeClient({ kernels: [replicad()], bundlers: [esbuild()], fileSystem: fromMemoryFS(), transport: createInProcessTransport(), }); ``` When to Use Each [#when-to-use-each] | Transport | Use when | | ---------------------------- | --------------------------------------------------------- | | Default (none specified) | Standard browser usage. Client auto-creates a worker. | | `createWorkerTransport(url)` | Custom worker URL or pre-built worker bundle. | | `createInProcessTransport()` | Testing, Node.js, or when worker isolation is not needed. | Related [#related] * [Worker Model](../concepts/worker-model) * [Architecture](../concepts/architecture) * [Quick Start](../getting-started/quick-start) -- End-to-end setup using the default transport