Quickstart
Set up a Dynamic Apps server, deploy an AI-generated application, connect the router, and verify the app from your browser.
View the complete Quickstart example on GitHub.
Install
npm add @rivet-dev/dynamic-apps
npm add @hono/node-server hono
npm add --save-dev tsx
npm pkg set type=module
Setup the server
Setup the HTTP server that will serve requests for AI-generated apps. Also set up the actors that power the deployments.
import { serve } from "@hono/node-server";
import { appsRouter } from "@rivet-dev/agentos-apps";
import { Hono } from "hono";
import { registry } from "./actors.js";
// Start the actor registry before routing applications.
registry.start();
const server = new Hono();
// Mount every deployed application at /apps/:appId.
server.route("/apps", appsRouter);
// Serve the host router over HTTP.
serve({
fetch: server.fetch,
port: 3000,
});
import { setup } from "@rivet-dev/agentos";
import { setupApps } from "@rivet-dev/agentos-apps";
const { appsActors } = setupApps();
export const registry = setup({
use: {
// These actors manage app deployments and scaling.
...appsActors,
},
});
Run the server:
npx tsx src/server.ts
Deploy an AI-generated app
Pass generated files directly to deployApp(). This can be called by an agent,
an upload endpoint, or any other part of your system:
import { deployApp } from "@rivet-dev/agentos-apps";
// An agent, upload endpoint, or any other part of the system can call
// deployApp() with the files it generated.
await deployApp({
appId: "hello-world",
files: {
"package.json": JSON.stringify({
name: "hello-world-app",
version: "0.0.0",
private: true,
type: "module",
main: "src/index.ts",
dependencies: {
hono: "^4.12.9",
},
}),
"src/index.ts": `
import { Hono } from "hono";
const app = new Hono();
// Serve the application's frontend.
app.get("/", (c) => c.html("<h1>Hello from agentOS Apps</h1>"));
// Serve a REST API request from the same application.
app.get("/api/hello", (c) => c.json({ message: "Hello from agentOS Apps" }));
export default app;
`,
},
});
npx tsx src/deploy.ts
Visit the AI-generated app
Open http://localhost:3000/apps/hello-world/. Pass this URL to agents,
frontends, or any other part of your system that needs to visit the deployment.
Deploy
By default, Rivet stores actor state on the local file system.
To scale Rivet in production, pick how much of it you want to run yourself:
Fully managed
Bring your own compute
Full self-hosting
If you are running your own workers, follow the guide for your hosting provider: