Sandboxes

Run code in isolated VMs

Run commands, edit files, and start services in an isolated VM. Sandboxes start in under 50 ms. Use a provided image or your own, and save memory snapshots to restore later.

Start for free Read the docs
Create, run, and snapshot with the SDK

Run code, tests, and development servers

Run coding agents

Let an agent install packages, edit files, and run tests in a separate VM. Choose an image with its tools installed, then read command output and collect the changed files.

Choose a base image

Share a running preview

Run a development server and expose its port through a URL. Review the application in a browser while the server runs. Require a token to restrict access to the preview.

Expose a service

Reuse your setup

Install dependencies, prepare the project, and take a memory snapshot. Start later sandboxes from that saved state. Mount a persistent volume for files that need to survive after a sandbox stops.

Create a snapshot

Edit files, run tests, review the app

Start a sandbox with the project's runtime and dependencies, then copy in the source files. An agent can edit the code and run the project's build and test commands. Read the command output to inspect failures and retrieve the changed files when the task is done.

For a web app, run its development server in the same VM and expose a port for browser review. Save a snapshot after dependency installation to reuse that setup for later tasks. Keep ongoing project files on a persistent volume, and stop the VM when you finish.

Create and stop sandboxes

Runtime, storage, and networking

Create and stop VMs through the SDK or CLI. Each VM has a runtime API for commands, files, and processes.

Runtime URLs

Each sandbox has an authenticated runtime URL for executing commands, managing processes, and reading or writing files.

Exposed ports

Expose a service running inside the VM through a public URL or require a token to access it.

Memory snapshots

Capture memory, running processes, and filesystem state. Restore the snapshot in a new sandbox.

Persistent volumes

Keep project files and dependency caches after a sandbox stops. Mount the same volume in other sandboxes within your team.

Base images

Choose an Ubuntu 24.04 image with Node, Python, Playwright Chromium, or an agent CLI such as Claude Code, Codex, or OpenClaw.

Custom images

Use the hx CLI to package a local Docker image for sandbox creation. Its environment variables and entrypoint are preserved.

Processes and terminal

Execute commands, start background processes, stream output, or open an interactive terminal.

Local filesystem

Read and write files, watch a directory for changes, and move files between the sandbox and your machine.

Network policies

Disable internet access or allow outbound traffic by domain, IP, or CIDR range. Deny traffic by IP or range. Update the policy while the VM runs.

Create a sandbox and run a command

  1. Start from an image or snapshot

    Choose a base image, custom image, or saved snapshot. Configure vCPU, memory, disk, and a timeout.

  2. Run code

    Run commands, start background processes, or open a terminal. Expose a port to access a service running in the sandbox.

  3. Save files and stop the VM

    Retrieve the output files or save them on a mounted volume. Take a snapshot if you need to restore the running environment. Stop the VM when finished, and set a timeout in case your code fails to close it.

These examples run a command, save a snapshot, and stop the VM. For Node or Python, set HYPERBROWSER_API_KEY in your environment. The CLI example requires hx authentication and jq.

1// yarn add @hyperbrowser/sdk2import { Hyperbrowser } from "@hyperbrowser/sdk";34const client = new Hyperbrowser({5  apiKey: process.env.HYPERBROWSER_API_KEY,6});78const sandbox = await client.sandboxes.create({9  imageName: "node",10  cpu: 2,11  memoryMiB: 2048,12  timeoutMinutes: 30,13});14console.log("Runtime URL:", sandbox.runtime.baseUrl);1516try {17  const result = await sandbox.exec("node -e 'console.log(2 ** 10)'");18  console.log(result.stdout); // 10241920  const snapshot = await sandbox.createMemorySnapshot({21    snapshotName: "node-after-setup",22  });23  console.log("Snapshot:", snapshot.snapshotId);24} finally {25  await sandbox.stop();26}
Setup and API reference

Sandbox pricing

Both vCPU and allocated memory are billed while the sandbox runs. 1 credit = $0.001.

UsageCreditsPrice
vCPU45 credits / vCPU-hour$0.045 / vCPU-hour
Memory15 credits / GiB-hour$0.015 / GiB-hour
All plans and rates

Common questions

How is a sandbox different from a browser session?

A browser session runs Chrome, which you control through an automation library. A sandbox is a VM where you can install packages, execute commands, edit files, and run services. Use it for tasks such as building an application or running a test suite.

Read more

Should I use a snapshot or a volume?

Use a snapshot to restore a VM's memory, processes, and files as they were when you saved it. Use a volume for files that change across runs, such as project files or caches. The volume remains available after the sandboxes using it stop.

Read more

Can I use my own environment?

Yes. Package a local Docker image with the hx CLI, then create sandboxes from it. The image supplies your dependencies, environment variables, and entrypoint. You can also start with a provided base image.

Read more

Can I restrict network access?

Yes. Disable internet access or allow outbound traffic to selected domains, IPs, or CIDR ranges. You can also deny IPs and ranges. Policies can change while the VM runs. Configure access to exposed services separately through port settings.

Read more

Other products

Start with a free account.

Includes 5,000 credits for browsers, sandboxes, and web data.