Skip to content

Connect a TypeScript backend

  1. Install hermitbox in your Node backend with its package manager.
  2. Set HERMITBOX_API_URL and HERMITBOX_API_KEY in the backend’s private environment.
  3. Run this module with your application’s normal TypeScript runner or build.
import { Hermitbox } from 'hermitbox'
// Connect with the URL and key from the environment.
const hb = new Hermitbox({
url: process.env.HERMITBOX_API_URL!,
key: process.env.HERMITBOX_API_KEY!,
})
// Use the install's default tier. A container also needs an image.
const { defaults } = await hb.project()
if (!defaults) throw new Error('The install did not report its default tier')
const { isolation } = defaults
const box = await hb.sandbox(
isolation === 'container' ? { isolation, image: 'alpine:3.22' } : { isolation },
)
try {
// Run a command and stop if it failed.
const result = await box.run('echo hello')
if (result.code !== 0) throw new Error(result.stderr)
console.log(result.stdout) // hello
} finally {
// Delete the sandbox, even when something failed.
await box.delete()
}

Keep this on the server: browser bundles must never contain a project key. On serverless platforms, await work inside the request lifetime or use a supported background worker; an unawaited promise may be terminated. Long streams need a runtime that permits their duration. The host tier still controls capabilities and isolation. SDK reference.

run it yourself
$curl -fsSL https://hbx.sh | sh
or ask your agent
Install Hermitbox and set it up for me
agents can read every page: llms.txt · llms-full.txt