# tinyactors · Verifiable logic for live systems Kind: pitch. For: [Workflow developer who tests](https://tinyactors.dev/audiences/workflow-tester.xml), [Agent-platform engineer](https://tinyactors.dev/audiences/agent-platform.xml), [Tech lead who approves dependencies](https://tinyactors.dev/audiences/tech-lead.xml). Voice: [Pitch](https://tinyactors.dev/voices/pitch.xml). > An open-source runtime for statecharts that you can simulate, inspect and update inside your application. tinyactors runs the rules that tell your application how to respond to events. Run those same rules in tests with a clock you control, then inspect the decisions they make in production. - **≈ 197 B** Per started WebSocket actor in Node.js ([source](https://tinyactors.dev/assets/homepage/websocket-capacity.json)) - **4 million** WebSocket actors measured in one process ([source](https://tinyactors.dev/assets/homepage/websocket-capacity.json)) - Node.js and Bun: `npm install @tinyactors/node` (@tinyactors/node 0.4.0, 19 November 2026 · [What changed](https://tinyactors.dev/changelog/index.md#node-0-4-0) · [Node.js and Bun guide](https://github.com/tinyactors-dev/tinyactors-napi#readme)) - Python: `pip install tinyactors` (tinyactors 0.4.0, 19 November 2026 · [What changed](https://tinyactors.dev/changelog/index.md#python-0-4-0) · [Python guide](https://github.com/tinyactors-dev/tinyactors-cpython#readme)) - Browsers: `npm install @tinyactors/wasm` (@tinyactors/wasm 0.4.0, 19 November 2026 · [What changed](https://tinyactors.dev/changelog/index.md#wasm-0-4-0) · [Browsers guide](https://tinyactors.dev/guides/browser/index.md)) - C: `curl -L https://github.com/tinyactors-dev/tinyactors-core/releases/download/v0.5.0/tinyactors-0.5.0-src.tar.gz | tar xz` (tinyactors-core 0.5.0, 26 November 2026 · [What changed](https://tinyactors.dev/changelog/index.md#c-0-5-0) · [C guide](https://github.com/tinyactors-dev/tinyactors/blob/main/tinyactors-core/docs/embedding.md)) [Start building](https://tinyactors.dev/docs/quickstart/index.md) · [Build with a coding agent](https://tinyactors.dev/docs/agents/index.md) · [Start the live anthill](https://tinyactors.dev/anthill/index.md) ## What to build with tinyactors - **[Background jobs](https://tinyactors.dev/recipes/index.md#workflows)**: Put retries, timeouts and cancellation in the job’s statechart. - **[Sessions and connections](https://tinyactors.dev/recipes/index.md#sessions)**: Give each session its own state, limits and timers. - **[Real-time applications](https://tinyactors.dev/recipes/index.md#realtime)**: Track subscriptions and connection state as clients join, leave and reconnect. - **[Multi-step workflows](https://tinyactors.dev/recipes/index.md#workflows)**: Coordinate approvals, deadlines and work waiting on other services. ## Run millions of actors in one process One process can host statecharts for individual jobs, connections and sessions. Each running chart is an actor with its own state, mailbox and timers. The [memory benchmark](https://tinyactors.dev/assets/homepage/websocket-capacity.json) starts four million WebSocket actors in Node.js with tracing enabled. The actors start online. Live sockets, requests and Redis subscriptions use additional memory. [Read the scaling results](https://tinyactors.dev/performance/index.md#scale) · [Measure on your device](https://tinyactors.dev/performance/index.md#lab) ## Simulate your system deterministically Start from the same state and repeat the same events, clock advances and service replies to reproduce a run. The rules are stored in a statechart, which describes how events move an actor from one state to another. - **[Control time and service replies](https://tinyactors.dev/guides/testing/index.md#reconnect-lab)**: Step through timeouts and retries with a simulated clock and handlers your tests supply. - **[Check a rule across many runs](https://tinyactors.dev/property-testing/index.md)**: Generate sequences in your tests and assert what must hold after each run. ## Deploy application logic in milliseconds Load a compiled chart into the process that’s already running. New actors start on the new version. For actors already running, choose when to [move them](https://tinyactors.dev/guides/migration/index.md#why-migrate). The running host loads version 2. A new actor starts there, and messages to an existing actor still reach it on version 1. An explicit migration moves that actor to version 2 under the same address. In a [Node.js benchmark](https://tinyactors.dev/guides/migration/index.md#load-time), at least 95 of 100 trials loaded a precompiled chart and started its first actor in under a millisecond. Moving existing actors is measured separately. [Read the migration guide](https://tinyactors.dev/guides/migration/index.md) ## Use the runtime you already have The same C engine powers the Node.js and Python bindings and the WebAssembly package. You can also embed it directly in a C application. - **[Node.js and Bun](https://tinyactors.dev/docs/node/index.md)**: Install the native binding for JavaScript and TypeScript. - **[Python](https://tinyactors.dev/docs/python/index.md)**: Run a host through the Python binding. - **[Browser](https://tinyactors.dev/guides/browser/index.md)**: Run charts in the browser with WebAssembly. - **[C](https://tinyactors.dev/docs/quickstart/index.md#run)**: Embed the core in a native application. ## Tools for development and production - **[Live inspection](https://tinyactors.dev/guides/inspection/index.md)**: Read an actor’s active states, variables, mailbox and delayed sends. - **[OpenTelemetry](https://tinyactors.dev/telemetry/index.md)**: Follow events and transitions across actors with traces, logs and metrics. - **[Chart checks in CI](https://tinyactors.dev/cli/guides/ci/index.md)**: Compile charts, check them for warnings and compare versions before deploying. - **[Snapshot inspector](https://tinyactors.dev/inspector/index.md)**: Open a captured host in the browser and inspect the state it held at capture time. - **[Actor hibernation](https://tinyactors.dev/guides/hibernation/index.md)**: Move idle actors out of memory through a store your application provides. - **[Coding agent support](https://tinyactors.dev/docs/agents/index.md)**: Give your agent the docs and the skill for writing and testing charts. ## Embed tinyactors in your application The host runs inside your process. Statecharts request outside work by sending events to handlers you supply. Those handlers connect to the services and storage your application already uses. [Read the architecture](https://tinyactors.dev/architecture/index.md) · [Connect your services](https://tinyactors.dev/guides/io-processors/index.md) ## Frequently asked questions - **Does tinyactors support Bun?**: Yes. The same [package supports Node.js and Bun](https://tinyactors.dev/docs/node/index.md). In Bun, run `bun add @tinyactors/node`. - **How does tinyactors compare to Temporal?**: Temporal’s service persists workflow history so workers can resume after failure. tinyactors runs statecharts in your process and your application owns durable state. [Compare tinyactors with Temporal](https://tinyactors.dev/compare/temporal/index.md). - **How does tinyactors compare to Cloudflare Durable Objects?**: Cloudflare gives each Durable Object a globally addressable identity and attached storage. tinyactors actors run in your application, which chooses how to route messages and where to store data. [Compare tinyactors with Durable Objects](https://tinyactors.dev/compare/durable-objects/index.md). - **How does tinyactors compare to Rivet?**: Rivet’s control plane places actors across machines and Rivet provides actor storage. tinyactors embeds a host in your process for actors that run statecharts. [Compare tinyactors with Rivet](https://tinyactors.dev/compare/rivet/index.md). - **Is tinyactors like Erlang, Akka or Orleans?**: All use message passing between stateful units. [Erlang processes](https://www.erlang.org/doc/system/ref_man_processes.html), [Akka actors](https://doc.akka.io/libraries/akka-core/current/typed/actors.html) and [Orleans grains](https://learn.microsoft.com/en-us/dotnet/orleans/overview) run behavior written in their host languages. Each tinyactors actor runs a statechart that your application can load as data. - **How is tinyactors different from XState?**: XState is a good fit for statecharts in JavaScript and TypeScript. With tinyactors, the chart is a separate file you can run in Python or C too, and load into a running host as a new version. [Compare tinyactors with XState](https://tinyactors.dev/compare/xstate/index.md). - **What is a statechart?**: A statechart describes the states a part of your application can be in, the events it responds to and the transitions those events cause. [Read how statecharts work](https://tinyactors.dev/docs/statecharts/index.md). - **What happens if the process stops?**: Actors live in process memory. Save the records your application needs to rebuild them, including any deadlines it must honor after a restart. Read the [recovery options](https://tinyactors.dev/when-to-use/index.md#crash). - **How do I run actors across machines?**: Run a host in each process and provide a [transport between hosts](https://tinyactors.dev/guides/other-systems/index.md). Your application handles actor placement and failover. - **Is tinyactors open source?**: Yes. The [source is MIT-licensed](https://github.com/tinyactors-dev/tinyactors/blob/main/LICENSE). The packages are at version 0.x and the APIs can still change. ## Build with verifiable logic Start with one part of your application. Put its rules in a statechart and test what happens as events arrive. [Start building](https://tinyactors.dev/docs/quickstart/index.md) · [Build with a coding agent](https://tinyactors.dev/docs/agents/index.md) --- # Documentation · tinyactors Kind: reference. For: [Agent-platform engineer](https://tinyactors.dev/audiences/agent-platform.xml), [Workflow developer who tests](https://tinyactors.dev/audiences/workflow-tester.xml), [Tech lead who approves dependencies](https://tinyactors.dev/audiences/tech-lead.xml). Voice: [Reference](https://tinyactors.dev/voices/reference.xml). > Everything about tinyactors in one place: the quickstart, the ideas behind statecharts and actors, the guides, the command line, the reference and the design. Start with one program that runs in five minutes. Then read the ideas, follow a guide for each task, and look up the rest. ## Start here - **[Quickstart](https://tinyactors.dev/docs/quickstart/index.md)**: Install one package and run an order actor that retries its payment on its own, in Node.js, Python, a browser or C. - **[Statecharts and actors in ten minutes](https://tinyactors.dev/docs/statecharts/index.md)**: States, events, transitions, timers and actors, with an order you can drive in the page. - **[Build a team chat](https://tinyactors.dev/chat/index.md)**: A tutorial of nine steps, from one room to direct messages, each a program that runs. - **[Build with a coding agent](https://tinyactors.dev/docs/agents/index.md)**: Give your agent the docs and the skill, and check what it writes in CI. ## Guides for each task - **[All guides](https://tinyactors.dev/guides/index.md)**: Writing and testing charts, connecting actors to your code, running a host in production and in the browser. - **[Test your charts](https://tinyactors.dev/guides/testing/index.md)**: Advance a simulated clock and see how a WebSocket reacts when a reconnect attempt succeeds or fails. - **[Keep waiting actors out of memory](https://tinyactors.dev/guides/hibernation/index.md)**: Two million actors ran with at most 1000 in memory and the rest in a database. - **[Change the chart of running actors](https://tinyactors.dev/guides/migration/index.md)**: Add a new version to the running process, and move each actor to it with the state it reached. - **[Journal and replay](https://tinyactors.dev/guides/journal/index.md)**: Record every input, and one loop rebuilds every actor after a crash. - **[Recipes](https://tinyactors.dev/recipes/index.md)**: Example applications named after what people build: order fulfillment, billing, a job scheduler, an HTTP gateway and more. ## Check and run charts from the command line - **[The tinyactors command](https://tinyactors.dev/cli/index.md)**: Compile, check, compare, draw and run charts, and read snapshots offline. - **[Tutorial](https://tinyactors.dev/cli/tutorial/index.md)**: From a draft chart with a misspelt event to a deploy you can compare. - **[CI checks](https://tinyactors.dev/cli/guides/ci/index.md)**: Fail a build when a chart has an error or its behavior changed. ## Look things up - **[Command reference](https://tinyactors.dev/cli/commands/index.md)**: Every command of the tinyactors command, with its options and examples. - **[@tinyactors/node API](https://tinyactors.dev/docs/node/index.md)**: Every class, function, interface and type of the Node.js and Bun package. - **[Python API](https://tinyactors.dev/docs/python/index.md)**: Every class, function and constant of the tinyactors package for Python. - **[The C library](https://github.com/tinyactors-dev/tinyactors/blob/main/tinyactors-core/docs/embedding.md)**: How to embed the core in C: the loop, lifetimes and memory. - **[Changelog](https://tinyactors.dev/changelog/index.md)**: What changed in each release of each package. - **[Memory, capacity and performance](https://tinyactors.dev/performance/index.md)**: What an actor costs, and the programs that measured it. ## Understand the design - **[When to use tinyactors](https://tinyactors.dev/when-to-use/index.md)**: What it fits, its limits, what a crash keeps, and how it compares with Temporal, Durable Objects, Rivet and XState. - **[Architecture](https://tinyactors.dev/architecture/index.md)**: How a host runs actors in your process, from the effects loop to the bytes of a snapshot. - **[The command line and the libraries](https://tinyactors.dev/cli/why/index.md)**: When to reach for the command, and when for a library in your program. - **[Why tinyactors exists](https://tinyactors.dev/about/index.md)**: Who makes it, and why. ## See it run - **[A million ants](https://tinyactors.dev/anthill/index.md)**: Two colonies in your browser, every ant an actor. - **[Property testing](https://tinyactors.dev/property-testing/index.md)**: A thousand generated runs of a payment, checked against rules in the page. - **[Telemetry](https://tinyactors.dev/telemetry/index.md)**: Every step of every actor as an OpenTelemetry span. - **[Snapshot inspector](https://tinyactors.dev/inspector/index.md)**: Open a snapshot and read every actor in it. --- # Quickstart · tinyactors Kind: how-to. For: [Agent-platform engineer](https://tinyactors.dev/audiences/agent-platform.xml), [Workflow developer who tests](https://tinyactors.dev/audiences/workflow-tester.xml). Voice: [How-to](https://tinyactors.dev/voices/how-to.xml). > Install tinyactors in Node.js, Python, a browser or C, and run an order actor that retries its payment on its own, in five minutes. Install one package and run one program. An order actor fills its cart, charges the card and retries on its own when the payment service is down. - Node.js and Bun: `npm install @tinyactors/node` (@tinyactors/node 0.4.0, 19 November 2026 · [What changed](https://tinyactors.dev/changelog/index.md#node-0-4-0) · [Node.js and Bun guide](https://github.com/tinyactors-dev/tinyactors-napi#readme)) - Python: `pip install tinyactors` (tinyactors 0.4.0, 19 November 2026 · [What changed](https://tinyactors.dev/changelog/index.md#python-0-4-0) · [Python guide](https://github.com/tinyactors-dev/tinyactors-cpython#readme)) - Browsers: `npm install @tinyactors/wasm` (@tinyactors/wasm 0.4.0, 19 November 2026 · [What changed](https://tinyactors.dev/changelog/index.md#wasm-0-4-0) · [Browsers guide](https://tinyactors.dev/guides/browser/index.md)) - C: `curl -L https://github.com/tinyactors-dev/tinyactors-core/releases/download/v0.5.0/tinyactors-0.5.0-src.tar.gz | tar xz` (tinyactors-core 0.5.0, 26 November 2026 · [What changed](https://tinyactors.dev/changelog/index.md#c-0-5-0) · [C guide](https://github.com/tinyactors-dev/tinyactors/blob/main/tinyactors-core/docs/embedding.md)) ## Write a chart and run it The packages need Node.js 22.3 or Bun, Python 3.13 or newer, or a C compiler. Save the chart as `order.scxml` and the program beside it, then run the program; the tabs follow the package you picked above. Node.js and Bun: ```javascript title="main.mjs" import { readFileSync } from 'node:fs'; import { compileCharts, Host } from '@tinyactors/node'; let charges = 0; const payments = { receive(send) { // the chart's console.log('charge', JSON.stringify(send.data)); if (++charges === 1) send.fail(); // down for the first charge: the order gets error.communication else send.answer('charged'); // an event back to the order }, }; const compiled = compileCharts([{ name: 'order.scxml', text: readFileSync('order.scxml', 'utf8') }]); const host = new Host(compiled, { system: 'shop', ioProcessors: { payments }, log: (entry) => console.log('log', entry.text), }); compiled.close(); const order = host.spawn('order'); order.send('add', { item: 'notebook', price: 30 }); order.send('add', { item: 'pen', price: 12 }); order.send('checkout'); console.log('paid', await order.done); // the order retried on its own host.close(); ``` ```scxml title="order.scxml" ``` Browsers: ```javascript title="browser.mjs" import { compileCharts, Host } from '@tinyactors/wasm'; let charges = 0; const payments = { receive(send) { // the chart's console.log('charge', JSON.stringify(send.data)); if (++charges === 1) send.fail(); // down for the first charge: the order gets error.communication else send.answer('charged'); // an event back to the order }, }; const chart = await fetch(new URL('order.scxml', import.meta.url)).then((response) => response.text()); const compiled = compileCharts([{ name: 'order.scxml', text: chart }]); const host = new Host(compiled, { system: 'shop', ioProcessors: { payments }, log: (entry) => console.log('log', entry.text), }); compiled.close(); const order = host.spawn('order'); order.send('add', { item: 'notebook', price: 30 }); order.send('add', { item: 'pen', price: 12 }); order.send('checkout'); console.log('paid', await order.done); // the order retried on its own host.close(); ``` ```scxml title="order.scxml" ``` Python: ```python title="main.py" import asyncio import json import tinyactors class Payments: charges = 0 def receive(self, send): # the chart's print("charge", json.dumps(send.data, separators=(",", ":"))) self.charges += 1 if self.charges == 1: send.fail() # down for the first charge: the order gets error.communication else: send.answer("charged") # an event back to the order async def main(): with open("order.scxml") as file: chart = file.read() with tinyactors.compile_charts([("order.scxml", chart)]) as compiled: host = tinyactors.Host(compiled, system="shop", io_processors={"payments": Payments()}, log=lambda entry: print("log", entry.text)) async with host: order = host.spawn("order") order.send("add", {"item": "notebook", "price": 30}) order.send("add", {"item": "pen", "price": 12}) order.send("checkout") print("paid", await order.done) # the order retried on its own asyncio.run(main()) ``` ```scxml title="order.scxml" ``` C: ```c title="main.c" /* cc main.c host.c -ltinyactors_datamodel_ecmascript -ltinyactors_runtime -ltinyactors -lm */ #include #include "host.h" typedef struct payments { int charges; } payments; /* What the order sends out, and how this program answers. */ static void handle(host *h, uint32_t effect) { payments *service = h->application; switch (ta_host_effect_number(h->host, effect, TA_EFFECT_FIELD_KIND)) { case TA_EFFECT_SEND: /* the chart's */ host_print(h, "charge", effect); if (++service->charges == 1) host_fail(h, effect); /* down: the order gets error.communication */ else host_answer(h, effect, "charged"); /* an event back to the order */ break; case TA_EFFECT_LOG: { /* the chart's */ ta_string_view text = ta_host_effect_text(h->host, effect, TA_EFFECT_FIELD_EVENT); printf("log %.*s\n", (int)text.length, text.pointer); break; } case TA_EFFECT_DONE: /* the order reached