HTTP Server
Start a Rivet node and expose health and metrics routes from your application's HTTP server.
Start a node
Call registry.start() to connect your app to the control plane and run Actors:
import { actor, setup } from "rivetkit";
const myActor = actor({ state: {}, actions: {} });
const registry = setup({ use: { myActor } });
registry.start();
Run the file with npx tsx --watch index.ts for Node.js, or bun --watch index.ts for Bun. In local development, RivetKit starts a control plane at http://localhost:6420. Actor clients connect to that control plane.
In production, set RIVET_ENDPOINT and run the process continuously. See Deploy Nodes.
Add health and metrics routes
Your app can run an HTTP server alongside its Rivet node. Mount registry.routes.health() and registry.routes.prometheusMetrics() in your router for probes and scraping:
import { serve } from "@hono/node-server";
import { Hono } from "hono";
import { actor, setup } from "rivetkit";
const counter = actor({ state: { count: 0 }, actions: {} });
const registry = setup({ use: { counter } });
registry.start();
const app = new Hono();
app.get("/health", () => registry.routes.health());
app.get("/metrics", (c) => registry.routes.prometheusMetrics(c.req.raw));
serve({ fetch: app.fetch, port: 3000 });
The app’s HTTP listener serves these routes. Actor requests continue to reach the node through its outbound connection to the control plane.
For Actor-specific HTTP handlers, see Low-Level HTTP Handler.