Skip to main content

Cookbooks

Step-by-step guides that build on Rivet Actors, with links to working templates and example code.

Type:
Tech:

AI Agent

Patterns for building an AI agent backend with persistent conversation memory: one Rivet Actor per conversation, queue-driven message handling, streaming LLM responses as realtime events, and sandboxed coding agents.

AI Agent

AI Agent Workspaces

Give every AI agent its own computer: a persistent agent workspace with a filesystem, processes, shells, networking, and coding agent sessions on a lightweight in-process VM. Run AI generated code, persist session transcripts across restarts, and mount a full sandbox when agents need native binaries.

agentOS

Chat Room

Build a realtime chat room backend with Rivet Actors. One actor per room key, SQLite-backed message history, and WebSocket broadcast of new messages to every connected client, plus extension patterns for typing indicators, presence, and per-user inboxes.

Chat Room

Collaborative Text Editor

Build a collaborative text editor backend with Yjs CRDTs and Rivet Actors: a per-document actor relays CRDT document sync and awareness updates to every collaborator, persists merged Yjs snapshots in actor KV, and a coordinator actor indexes documents per workspace.

Collaborative Document

Cron Jobs and Scheduled Tasks

Durable cron jobs and scheduled tasks with Rivet Actors. Use c.schedule.after and c.schedule.at for persistent timers that survive restarts, deploys, and crashes, plus recurring jobs that re-arm themselves, idempotent handlers, and singleton job actors.

Scheduling

Database per Tenant

Multi-tenant data isolation with one Rivet Actor per tenant. The actor key is the tenant id, so each tenant gets its own actor and its own isolated dataset with no shared tables. Covers JSON state vs SQLite vs Drizzle, migrations, and deriving the tenant id from auth.

Per-Tenant Database

Live Cursors and Presence

Patterns for live cursors and multiplayer presence with Rivet Actors: per-connection cursor state, realtime cursor sharing over typed events or raw WebSockets, presence join and leave cleanup, and update throttling guidance.

Live CursorsLive Cursors (Raw WebSocket)

Multiplayer Game

Pragmatic patterns for building multiplayer games: matchmaking, tick loops, realtime state, interest management, and validation.