Capabilities
State & Data
Durable SQLite state and queued work inside an app.
Agents can generate more than pages and REST APIs. These examples show apps with durable SQLite data, workflows, multiplayer state, queues, and scheduled jobs. The server snippets represent AI-generated app code; the client snippets show how another part of your system connects to it.
SQLite
Example AI-generated app code that stores durable data in an actor-owned SQLite database. View the complete SQLite example.
import { actor, setup } from "rivetkit";
import { db } from "rivetkit/db";
const notes = actor({
db: db({
async onMigrate(database) {
await database.execute(`
CREATE TABLE IF NOT EXISTS notes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
body TEXT NOT NULL
)
`);
},
}),
actions: {
async add(c, body: string) {
await c.db.execute("INSERT INTO notes (body) VALUES (?)", body);
},
async list(c) {
return c.db.execute("SELECT id, body FROM notes ORDER BY id");
},
},
});
export const registry = setup({
use: { notes },
});
registry.start();
export default function fetch() {
return Response.json({
app: "sqlite-notes",
message: "Use the RivetKit client to add and list notes.",
});
}
import type { Deployment } from "@rivet-dev/agentos-apps";
import { createClient } from "rivetkit/client";
import type { registry as appRegistry } from "../fixtures/app/src/index.js";
const response = await fetch("http://localhost:3000/deploy/sqlite-notes", {
method: "POST",
});
if (!response.ok) {
throw new Error(`deployment failed: ${response.status} ${await response.text()}`);
}
const deployment = (await response.json()) as Deployment;
const client = createClient<typeof appRegistry>({
namespace: deployment.namespace,
poolName: deployment.pool,
});
try {
const notes = client.notes.getOrCreate(["shared"]);
await notes.add("Hello from the RivetKit client");
console.log(await notes.list());
} finally {
await client.dispose();
}
Queues
AI-generated apps can use actor queues for durable background work and ordered processing.