Skip to Content
PlatformServerless Compute

Serverless Compute

Serverless Compute runs web apps, APIs, agents, and backend workers without managing servers. Deploy code with a start command, choose a region when needed, and let StackMachine handle app versions, runtime logs, and request traffic.

Features

App processes

Deploy any HTTP service that listens on the provided PORT. StackMachine treats each deployment as an app version that can be observed and replaced.

Regional placement

Pass region when you want a workload close to users, databases, or third-party APIs.

Environment variables

Attach plain or sensitive environment variables at deploy time. Sensitive values are hidden in the dashboard after creation.

Logs and versions

Use app versions and logs to inspect runtime behavior after deploys. The same app identity can receive new versions over time.

Common workflow

  1. Package an HTTP service with a start command.
  2. Deploy it with client.deployments.create and wait for the version.
  3. Use the app URL for traffic and the app version ID for log queries.

SDK examples

Deploy an API worker

Deploy a Hono-based API with a health check and task endpoint.

serverless-compute.js
1
const deployment = await client.deployments.create({
2
  appName: "api-worker",
3
  owner: "stackmachine",
4
  region: "iad",
5
  files: {
6
    "package.json": JSON.stringify({
7
      type: "module",
8
      scripts: { start: "node server.js" },
9
      dependencies: { "@hono/node-server": "latest", hono: "latest" },
10
    }),
11
    "server.js": [
12
      'import { serve } from "@hono/node-server";',
13
      'import { Hono } from "hono";',
14
      "",
15
      "const app = new Hono();",
16
      'app.get("/health", (c) => c.json({ ok: true }));',
17
      'app.post("/tasks/process", async (c) => {',
18
      " const payload = await c.req.json();",
19
      " return c.json({ accepted: true, payload });",
20
      "});",
21
      "",
22
      "serve({ fetch: app.fetch, port: Number(process.env.PORT || 3000) });",
23
    ].join("\n"),
24
  },
25
  installCmd: "npm install",
26
  startCmd: "npm start",
27
  envVars: [{ name: "NODE_ENV", value: "production", sensitive: false }],
28
});
29
 
30
const appVersion = await deployment.wait({
31
  onProgress: ({ stream, message }) => console.log(stream, message),
32
});
33
console.log(appVersion.app.url);

Source: stackmachine/sdks  JavaScript examples.