Templates
A template makes new sandboxes start ready to work, with dependencies installed and builds done. You prepare a sandbox once and save it as a snapshot. Every sandbox made from it starts in that state, and installs and builds never run again per sandbox.
Hermitbox also ships templates for interpreters, a browser, a desktop and 54 starter projects, and makes one from a Git repository with one command (Built-in templates).
| Part | What it holds |
|---|---|
| Source | An image on container, gvisor or vm, or no image on process or wasm |
| Build | Files copied in, commands run, and an optional readiness check |
| Snapshot | The prepared data directory, saved as an immutable version |
| Start command | What runs in each new sandbox, in its data directory unless workdir says otherwise |
| Tier | The tier the snapshot was made on; every sandbox from it runs there too |
Start from a template
Pass the template’s name or ID when you create a sandbox. Hermitbox forks the newest version’s snapshot and runs its start command, so the sandbox starts with the template’s work already done.
// Each sandbox from it starts with the dependencies installed.
const box = await hb.sandbox({ template: 'my-api' })# Each sandbox from it starts with the dependencies installed.
box = hb.sandbox(template='my-api')use hermitbox::SandboxOptions;
// Each sandbox from it starts with the dependencies installed.
let sandbox = hb.create_sandbox(SandboxOptions::new().template("my-api")).await?;A create takes exactly one source: an image, a snapshot or a template. A sandbox from a
template is an ordinary fork: it has its own ID and data, and changes never reach the template.
Build one from code
Describe a template in your own code. hb.template starts a sandbox from from, copies your
files in, runs each run command, and snapshots the result. The copy happens from your machine;
only the build plan and the finished snapshot reach control.
// Copy the project in, install its dependencies, and save the result.
const template = await hb.template({
name: 'my-api',
from: 'node:22',
copy: [['./', 'app']],
run: ['cd /data/app && npm ci'],
start: 'cd app && npm start',
})# Copy the project in, install its dependencies, and save the result.
template = hb.template(
name='my-api',
from_='node:22',
copy=[('./', 'app')],
run=['cd /data/app && npm ci'],
start='cd app && npm start',
)use hermitbox::TemplateOptions;
// Copy the project in, install its dependencies, and save the result.
let template = hb
.template(
TemplateOptions::new("my-api")
.from_image("node:22")
.copy_path("./", "app")
.run_step("cd /data/app && npm ci")
.start("cd app && npm start"),
)
.await?;Each run and ready command has up to ten minutes. A failed step says how it ended (its exit
code, a signal or a timeout), and the build deletes its sandbox. The CLI runs the same builder from
a file: hermitbox template build -f hermitbox.template.ts.
Template versions
Rebuild a template when its project changes. Each build registers a new, numbered version, and a
version never changes. template.rebuild() builds the next one from the same local files. New
sandboxes start from the newest version, and hb.templates() lists them.
A snapshot that a version uses can’t be deleted, and neither can the sandbox that built it, while that version exists.
Templates from a spec
POST /v1/templates takes a name and a spec: the same fields as a create, such as image,
isolation, entrypoint and env, with no snapshot or template as its source. Control prepares
it once on each active node that serves the spec’s tier and keeps a stopped snapshot there. A
sandbox from it forks a ready copy in its region.
Bucket mounts carry credentials, so a template never stores them. Pass them when you create each sandbox.
Built-in templates
Common runtimes, tools and full starter stacks work without writing a build plan first. Hermitbox
ships three kinds of built-in templates for the container tier.
Runtime and tool plans
hermitbox template create <name> prepares Hermitbox’s released container images (or an
operator-built image with --image):
| Template | What it provides |
|---|---|
python-interpreter |
CPython 3.12 with a prestarted IPython kernel and scientific libraries (box.python()) |
node-interpreter |
Node.js 24 with a prestarted IJavascript kernel and Chart.js (box.javascript()) |
browser |
Headless Chromium and Playwright with screenshots and expiring CDP URLs (box.browser()) |
desktop |
X11 desktop (Xvfb, JWM, noVNC) with computer-use actions and note preview (box.desktop()) |
tools |
OpenSSH and rclone for interactive SSH sessions and S3/R2 bucket mounts (box.ssh(), box.mount()) |
sandbox-agent |
Rivet’s sandbox-agent server on private port 3000 for runner harnesses |
Starter projects
Passing a starter name such as nextjs, vite-react or fastapi to hb.sandbox({ template })
prepares a warm, tested snapshot on a container-capable node the first time a sandbox asks for it,
then forks a copy with a ready preview URL.
Hermitbox ships 54 starters across
frontend and full-stack web,
JS/TS backends,
Python web,
native and compiled backends,
databases and caches,
vector stores,
notebooks, local search and AI, and
browser automation and desktop.
Compatible starters also accept services: ['postgres'] or services: ['redis'] to warm a
fork-local database or cache alongside the app.
Git repositories
Point Hermitbox at a repository and get a running copy with a preview URL.
hermitbox template from <repo> inspects an HTTPS repository or local Git checkout, infers its
image, install command, start command and port, builds a template from the committed files, and
launches a fork with a preview URL.
Next steps
- Built-in templates: every runtime, tool and starter template Hermitbox ships.
- Templates from code: build custom templates, compose services and import Git repositories.
- Code interpreters and Native tools: deep dives on interpreters, browsers, desktops, SSH and mounts.
- Lifecycle: how snapshots and forks work.
$curl -fsSL https://hbx.sh | shInstall Hermitbox and set it up for me