SessionPersistDriver to store session records and event history.
If you do not provide one, the SDK uses in-memory storage.
With persistence enabled, sessions can be restored after runtime/session loss. See Session Restoration.
Each driver stores:
SessionRecord(id,agent,agentSessionId,lastConnectionId,createdAt, optionaldestroyedAt, optionalsandboxId, optionalsessionInit, optionalconfigOptions, optionalmodes)SessionEvent(id,eventIndex,sessionId,connectionId,sender,payload,createdAt)
Persistence drivers
Rivet
Recommended for sandbox orchestration with actor state. See Multiplayer for a full Rivet actor example with persistence in actor state.IndexedDB (browser)
Best for browser apps that should survive reloads. See the Inspector source for a complete IndexedDB driver you can copy into your project.In-memory (built-in)
Best for local dev and ephemeral workloads. No extra dependencies required.SQLite
Best for local/server Node apps that need durable storage without a DB server.Postgres
Use when you already run Postgres and want shared relational storage.Custom driver
ImplementSessionPersistDriver for custom backends.
Replay controls
SandboxAgent.connect(...) supports:
replayMaxEvents(default50)replayMaxChars(default12000)