# NodeAkt

> A TypeScript-first distributed actor framework for Node.js, Bun, and Deno with typed messages, supervision, clustering, and zero dependencies.

NodeAkt is a TypeScript-first distributed actor framework for Node.js, Bun, and Deno, released under the MIT License by the GoAkt Team. It lets developers build concurrent, resilient, and elastic systems using the actor model — where each actor owns private state and a mailbox, and the runtime delivers messages one at a time, eliminating the need for locks or shared-state management. The project reached v0.2.0 in August 2026 and is available as a single npm package with zero external dependencies.

## What It Is

NodeAkt brings the actor model — popularized by Erlang/OTP — to the TypeScript ecosystem. An actor is a small unit of computation that communicates exclusively through messages; it never shares memory with other actors. Because the runtime delivers messages one at a time, there is no concurrency inside a handler, which means no races, no locks, and no shared-state bugs. NodeAkt extends this model to multi-core machines and multi-node clusters, all behind the same PID-based API.

## Core Runtime Capabilities

NodeAkt ships a full actor runtime with several built-in primitives:

- **Typed messages**: Messages are plain TypeScript classes narrowed with `instanceof`. `tell` is fire-and-forget; `ask` waits for a typed reply.
- **Supervision**: Stop, resume, restart, or escalate on failure. Supports one-for-one and one-for-all strategies, restart budgets, and exponential backoff.
- **Behaviors and stash**: `become` and `becomeStacked` swap the message handler at runtime; the stash replays deferred messages after a switch.
- **Mailboxes**: Unbounded and bounded FIFO, segmented, fair per-sender, and priority mailboxes — or implement a custom one.
- **Scheduling**: `pipeTo` turns a promise's result into a message; reentrant requests keep the mailbox moving while a reply is in flight; schedules deliver on a delay or interval.
- **Multi-core**: Spawn actors across every CPU core without touching workers or threads directly. The same PID API works locally and across isolates.

## Networking and Clustering

NodeAkt supports both remoting and full cluster formation:

- **Remoting over TCP**: Look up, spawn, watch, and message actors on another node. `tell`, `ask`, `request`, `forward`, `pipeTo`, and death watch all cross the wire, including failures.
- **TLS**: Encrypt remoting with a certificate, key, and optional CA. Mutual TLS is supported; the protocol is unchanged over the encrypted carrier.
- **Clustering**: Enable with a discovery provider and a remote endpoint. Membership, a distributed name registry, and remoting join into one cluster of location-transparent actors.
- **Discovery**: Find seed peers over DNS or a static list at boot, then track membership with gossip and failure detection. A quorum guards against split brain.
- **Placement**: `spawn` keeps an actor local; `spawnOn` places it on the node a strategy chooses. Top-level names are unique cluster-wide.
- **Singletons**: `spawnSingleton` gives a name exactly one live instance cluster-wide, pinned to the coordinator and idempotent to create.
- **Relocation**: When a node departs — gracefully or by crash — the coordinator recreates its relocatable actors on the survivors from their recipes.

## Runtime Support and Zero Dependencies

NodeAkt targets Node.js 22+, Bun 1.3+, and Deno 2+, and is distributed as an ESM-only package (`import`, not `require`). The entire library — including the multi-core layer and the network protocol — is built on the standard library alone. Installing it brings exactly one package. Every supported runtime is exercised in CI, including multi-core placement.

## Update: v0.2.0

The latest release is v0.2.0, published on August 28, 2026. The repository was created on August 21, 2026, making this a very recently launched project. The GitHub tracking issue references the related GoAkt project (a Go-based actor framework by the same team), suggesting NodeAkt is the TypeScript sibling of an established Go implementation. Community discussion happens via GitHub Issues and a Slack workspace.

## Features
- Typed actor messages with instanceof narrowing
- tell (fire-and-forget) and ask (typed reply) messaging
- Supervision trees: stop, resume, restart, escalate
- One-for-one and one-for-all supervision strategies with restart budgets and exponential backoff
- Behaviors: become and becomeStacked for runtime handler swapping
- Stash for replaying deferred messages after behavior switch
- Multiple mailbox types: unbounded FIFO, bounded FIFO, segmented, fair per-sender, priority
- Multi-core actor placement across CPU cores
- Remoting over TCP: spawn, look up, watch, and message actors on remote nodes
- TLS encryption for remoting with optional mutual TLS
- Clustering with distributed name registry and location-transparent actors
- Peer discovery via DNS or static list
- Gossip-based membership and failure detection with quorum
- Cluster-wide actor placement strategies
- Cluster singletons with spawnSingleton
- Actor relocation on node departure or crash
- pipeTo for turning promise results into messages
- Reentrant requests to keep mailbox moving during in-flight replies
- Scheduled message delivery: delay and interval
- Zero external dependencies
- ESM-only package
- Supports Node.js 22+, Bun 1.3+, and Deno 2+

## Integrations
Node.js, Bun, Deno, npm, pnpm, yarn, DNS (for cluster discovery)

## Platforms
API, CLI, DEVELOPER_SDK

## Pricing
Open Source

## Version
v0.2.0

## Links
- Website: https://tochemey.github.io/nodeakt/
- Documentation: https://tochemey.github.io/nodeakt/guide/
- Repository: https://github.com/Tochemey/nodeakt
- EveryDev.ai: https://www.everydev.ai/tools/nodeakt
