Connect a TypeScript backend
Connect my Node or Bun backend to Hermitbox.
Give your Node or Bun backend sandboxes: create one, run a command in it and delete it with the TypeScript SDK.
Install the SDK from npm:
npm install hermitboxQuickstart
import { Hermitbox } from 'hermitbox'
const hb = new Hermitbox()
const box = await hb.sandbox()
console.log((await box.run('echo hello')).stdout.trim())
await box.delete()On the machine where you installed Hermitbox, new Hermitbox() connects automatically. From
another machine, set HERMITBOX_API_URL and HERMITBOX_API_KEY in the backend’s private
environment.
Snapshot and fork
Try a risky change without touching the original. Save a sandbox at a clean checkpoint, fork an independent copy, change the fork and throw it away:
import { Hermitbox } from 'hermitbox'
const hb = new Hermitbox()
const box = await hb.sandbox()
try {
await box.write('config.json', '{"mode":"safe"}')
const snapshot = await box.snapshot()
const fork = await snapshot.fork()
try {
await fork.write('config.json', '{"mode":"experimental"}')
console.log('original:', await box.read('config.json'))
console.log('fork:', await fork.read('config.json'))
} finally {
await fork.delete()
}
} finally {
await box.delete()
}Output:
original: {"mode":"safe"}
fork: {"mode":"experimental"}Keep this code on the server. A browser bundle must never contain a project key. On serverless platforms, await work inside the request lifetime or use a supported background worker: the platform can stop an unawaited promise when the request ends.
Long streams need a runtime that permits their duration. The host tier still controls capabilities and isolation. SDK reference.
$curl -fsSL https://hbx.sh | shInstall Hermitbox and set it up for me