Skip to main content
Workloads

Backends & REST APIs

Serve HTTP APIs and frontends from a generated app with any framework that speaks fetch.

Prefer to read code? Clone the example repository. View on GitHub

Example generated code

Deploy and route

Deploy the directory and every route the app defines is served under /apps/:appId on your routing server:

import { serve } from "@hono/node-server";
import { appsRouter } from "@rivet-dev/dynamic-apps";
import { Hono } from "hono";

const server = new Hono();

// This is how the Rivet control plane communicates with your backend.
server.all("/api/rivet/*", (c) => appsRouter.fetch(c.req.raw));

// Mount every deployed application at /apps/:appId.
server.route("/apps", appsRouter);

// Serve the host router over HTTP.
serve({
	fetch: server.fetch,
	port: 3000,
});

See Route for how requests reach the app and Deploy for builds and releases.