ActorCore
The Stateful Serverless Framework
Build AI agents, realtime apps, game servers, and more.
Supports Rivet, Cloudflare Workers, Bun, and Node.js.
Resources
Getting Started
Step 1: Installation
npm add actor-core
pnpm add actor-core
yarn add actor-core
bun add actor-core
Step 2: Create an Actor
import { Actor, type Rpc } from "actor-core";
export interface State {
messages: { username: string; message: string }[];
}
export default class ChatRoom extends Actor<State> {
_onInitialize() {
return { messages: [] };
}
sendMessage(rpc: Rpc<ChatRoom>, username: string, message: string) {
this._state.messages.push({ username, message });
this._broadcast("newMessage", username, message);
}
}
Step 3: Connect to Actor
import { Client } from "actor-core/client";
import type ChatRoom from "../src/chat-room.ts";
const client = new Client();
const chatRoom = await client.get<ChatRoom>({ name: "chat" });
chatRoom.on("newMessage", (username: string, message: string) =>
console.log(`Message from ${username}: ${message}`),
);
await chatRoom.sendMessage("william", "All the world's a stage.");
Step 4: Deploy
Deploy to your platform of choice:
License
Apache 2.0