Skip to content

Topology & local runtime

You have a behavior. To run it, place it in a topology and start a runtime.

1. Declare a topology

ts
import { defineActorWebTopology, actor, node } from '@actor-web/runtime/topology';

export const topology = defineActorWebTopology({
  nodes: { local: node('local') },
  actors: {
    counter: actor({ id: 'counter', node: 'local', behavior: counter }),
  },
});

2. Start a local runtime

startRuntime runs the whole topology in-process — perfect for the browser and tests:

ts
import { startRuntime } from '@actor-web/runtime';

const runtime = await startRuntime(topology);

3. Drive the actor

Each actor exposes source factories. A command-capable source can both observe and send:

ts
const counter = runtime.actors.counter.commands();

await counter.ask({ type: 'INCREMENT' });
console.log(counter.snapshot().context.count); // 1

For a UI, prefer readModel() for display-only components — see Sources & the gateway and the Ignite Element guide.

4. Stop

ts
await runtime.stop();

Next