alepha@docs:~/docs/packages/alepha$
cat actor.md | pretty
2 min read
Last commit:

#Alepha - Actor

#Installation

Part of the alepha package. Import from alepha/actor.

npm install alepha

#Overview

Pure synchronous JSON reducers with independent default/keyed snapshots.

On Node and Bun, REDIS_URL selects Redis: every instance shares actor state, and every $rateLimit becomes cross-instance. Without it, state is volatile per-container Memory, one instance. An app's own ActorProvider substitution wins over both.

With Redis, every actor identity carries alepha.name (APP_NAME, else the build's app name, else "app"), so two apps on one Redis never share actor state. Durability depends on Redis persistence, eviction and failover configuration, without exactly-once claims. Only definite compare-and-set conflicts retry pure reducers; transport failures propagate without replay because a commit can have succeeded before the error.

#API Reference

#Primitives

  • $actor - Declare independent default and keyed actor state from an atom descriptor.

#Providers

  • ActorCodec - Lossless JSON snapshots and protocol-v1 validation shared by actor providers.
  • ActorHost - One instance's serialized protocol KV snapshots on SQLite-backed storage.
  • ActorHostRegistry - Runtime-neutral native-host declarations, visible without starting the app.
  • ActorHostRuntime - Common app/environment resolution, namespace lookup and specialized startup.
  • ActorProvider - Actor snapshot transport. Browser and native execution is unsupported.
  • ActorRedisConnection - Injection token for an existing runtime Redis provider's get/eval seam.
  • ActorRegistry - Per-container declaration allowlist, independent of the local atom store.
  • AlephaActorDurableObject - Native workerd-only adapter for the shared actor host.
  • BunActorRedisProvider - Existing Bun Redis operations with offline command replay disabled.
  • CloudflareActorProvider - Routes independent encoded actor identities to the shared native host.
  • MemoryActorProvider - Volatile actor snapshots scoped to one container, serialized per identity.
  • NodeActorRedisProvider - Existing Node Redis operations with offline command replay disabled.
  • RedisActorProvider - One-key exact-byte CAS of validated actor envelopes using Redis eval.