Overview
Actors for long-lived processes with durable state, realtime, and hibernate when not in use.
Quickstart
Node.js & Bun Quickstart
Set up Rivet with Node.js, Bun, and web frameworks
React Quickstart
Set up Rivet with React
Next.js Quickstart
Set up Rivet with Next.js
Cloudflare Workers Quickstart
Set up Rivet with Cloudflare Workers
Features
- Long-Lived, Stateful Compute: Each unit of compute is like a tiny server that remembers things between requests – no need to re-fetch data from a database 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: Update state and broadcast changes in realtime with WebSockets or SSE. No external pub/sub systems, no polling – just built-in low-latency events.
- Infinitely Scalable: Automatically scale from zero to millions of concurrent actors. Pay only for what you use with instant scaling and no cold starts.
- Fault Tolerant: Built-in error handling and recovery. Actors automatically restart on failure while preserving state integrity and continuing operations.
Use Cases
Actors are perfect for applications that need persistent state and real-time updates:
- AI agents: Stateful AI assistants with conversation history
- Collaborative documents: Multiple users editing documents simultaneously (Yjs integration)
- Local-first sync: Offline-first applications with server synchronization
- Per-tenant databases: Isolated data stores for each user or tenant
- Background job: Background & time-based task execution with persistent state
- Rate limiting: Distributed rate limiting with persistent counters
- Stream processing: Real-time data processing with persistent state
Core Concepts
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 & Events
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
Rivet provides end-to-end TypeScript safety between clients and actors: