website/src/content/posts/2026-02-26-sqlite-for-rivet-actors/page.mdx
Today we're releasing SQLite for Rivet Actors: embedded, per-actor SQLite databases that run at the edge.
useActorDefine db on your actor and you get a full SQLite database scoped to that actor instance. No connection strings, no provisioning, no config.
import { actor, setup } from "rivetkit";
import { db } from "rivetkit/db/drizzle";
import { integer, sqliteTable, text } from "rivetkit/db/drizzle";
import { eq } from "drizzle-orm";
// Auto-generated by `drizzle-kit generate`
import migrations from "./drizzle/migrations.js";
// Define typed schema
const todos = sqliteTable("todos", {
id: integer("id").primaryKey({ autoIncrement: true }),
title: text("title").notNull(),
completed: integer("completed").notNull().default(0),
});
const schema = { todos };
const todoList = actor({
// Drizzle handles migrations automatically from generated files
db: db({ schema, migrations }),
actions: {
addTodo: async (c, title: string) => {
// Typed insert with .returning()
const rows = await c.db.insert(todos).values({ title }).returning();
return rows[0];
},
toggleTodo: async (c, id: number) => {
// Typed select with .where()
const current = await c.db
.select()
.from(todos)
.where(eq(todos.id, id));
if (current.length > 0) {
await c.db
.update(todos)
.set({ completed: current[0].completed ? 0 : 1 })
.where(eq(todos.id, id));
}
},
getTodos: async (c) => {
// Typed results, no manual casting
return await c.db.select().from(todos).orderBy(todos.id);
},
},
});
export const registry = setup({ use: { todoList } });
Combine SQLite with actor events and useActor to build realtime apps. Writes persist to SQLite and broadcast to every connected client instantly.
Browse and query your actor databases directly from the Rivet Hub. Select any actor instance to view its tables, run queries, and inspect data in realtime.
Every actor instance gets its own SQLite database. Spin up millions of isolated databases, one per user, one per workspace, one per document. No connection pools, no row-level security, no per-tenant configuration.
Compute and storage live on the same machine. Queries read from local memory, not over the network to an external database. No connection overhead, no round trips.
Actors hibernate when idle. A database with no traffic costs nothing. When a request arrives, the actor wakes up with its full SQLite database intact. You only pay for what you use.
Rivet Actors run at the edge, close to your users. Combined with actor events and WebSockets, you get a realtime data layer with no additional infrastructure. Write to SQLite, broadcast the change, and every connected client sees it instantly.
Rivet is the only multi-tenant SQLite platform that's open-source. Apache 2.0. Deploy on Cloudflare Workers, Vercel, Railway, or your own infrastructure. No vendor lock-in.
Plus everything else that comes with Rivet Actors: scale to millions of instances, TypeScript-native, WebSocket events, queues, state, and workflows.
SQLite is available today in RivetKit.
npm install rivetkit
import { db } from "rivetkit/db";