Actors Overview
Stateful serverless functions with persistence, real-time communication, and automatic scaling
Actors are lightweight, stateful serverless functions that maintain persistent state and provide real-time communication. They’re the core building blocks of RivetKit applications.
Getting Started
Backend Quickstart
Set up actors with Node.js, Bun, and web frameworks
React Quickstart
Build real-time React applications with actors
Key Features
Long-Lived, Stateful Compute
Each unit of compute is like a tiny server that remembers things between requests – no need to reload data or worry about timeouts. Like AWS Lambda, but with memory and no timeouts.
Blazing-Fast Reads & Writes
State is stored on the same machine as your compute, so reads and writes are ultra-fast. No database round trips, no latency spikes.
Realtime, Made Simple
Update state and broadcast changes in realtime. No external pub/sub systems, no polling – just built-in low-latency events.
Store Data Near Your Users
Your state lives close to your users on the edge – not in a faraway data center – so every interaction feels instant.
Use Cases
Actors are perfect for applications that need persistent state and real-time updates:
Real-time Communication
- Chat rooms: Real-time messaging with message history and user presence
- Collaborative documents: Multiple users editing documents simultaneously
- Live events: Broadcasting updates to many participants
AI & Automation
- AI agents: Stateful AI assistants with conversation history
- Workflow automation: Long-running business processes with state persistence
- Stream processing: Real-time data processing with persistent state
Data & Synchronization
- Local-first sync: Offline-first applications with server synchronization
- Per-user databases: Isolated data stores for each user or tenant
- Per-tenant SaaS: Multi-tenant applications with isolated state
- CRDT collaboration: Conflict-free replicated data types for real-time editing
Gaming & Interactive Applications
- Multiplayer games: Game state management with real-time updates
- Rate limiting: Distributed rate limiting with persistent counters
State Management
Actors maintain persistent state that survives restarts, crashes, and deployments. State can be defined as a constant or created dynamically:
Learn more about state management.
Actions
Actions are the primary way to interact with actors. They’re type-safe functions that can modify state and communicate with clients:
Actions can be called from your backend, your clients, or other actors:
Learn more about actions and communicating with actors.
Real-time Communication
Actors support real-time bidirectional communication through WebSocket and SSE connections. Clients can establish persistent connections to receive live updates.
For example, to send events to all connected clients:
Clients connect and listen for real-time updates:
Learn more about events and client communication.
Scheduling & Lifecycle
Actors support scheduled tasks and lifecycle management:
Learn more about actor lifecycle.
Type Safety
RivetKit provides end-to-end TypeScript safety between clients and actors: