Skip to main content
1

Install the CLI

That gives you nsbx. There is no binary to download and no runtime to install — the container engine already on your host is the runtime.Or skip the install entirely and prefix every command with npx nativesandbox instead:
Under nvm, a global install lands in the current Node version’s directory, so switching versions hides nsbx until you install it there too.
2

Run something

That creates a sandbox, runs the command, streams the output back and removes the sandbox. If it fails, the next step says why.
3

Check the host

Anything it finds, it explains and offers to fix:
setup prints each command, says whether it needs root, and waits for you to agree before running it. Nothing happens to your machine that you have not seen first. See the CLI for the full check list.
4

Install the library

Node 22 or newer. Zero runtime dependencies. This is the library, separate from the CLI in step 1 — a project depends on it, rather than installing it globally.
5

Create a sandbox and run a command

The name is yours and is how you find the sandbox again. Calling create() with the same name returns the same sandbox while its shape still serves the request — see sandboxes.
memory is a branded type, so memory: 512 will not compile. Write the unit — MiB(512), GiB(2) — and the ambiguity between megabytes, mebibytes and bytes cannot reach the engine.
6

Move files in and out

These are host reads and writes, because the workspace is a bind mount rather than a channel to a guest. box.workspaceDir is the directory on the host, and reading it is reading the sandbox.
7

Clean up

Or from the terminal:

What happens when you create a sandbox

  1. The image is pulled if it is not already cached — slow the first time, instant afterwards.
  2. A workspace directory is created on the host and bind-mounted at /workspace.
  3. A container starts with your memory, CPU and PID limits applied through cgroups, every Linux capability dropped, and no-new-privileges set.
  4. It idles on sleep infinity, so every later command is an exec into the same sandbox and whatever the last command installed is still there.
  5. If it goes quiet for five minutes it stops, keeping the workspace. After an hour it is retired and rebuilt fresh over the same warm workspace.
Steps 4 and 5 are why reuse is worth having: the second npm install in a sandbox is free.

A complete example

Next

Requirements

What the host needs, and how to prove it has it.

The CLI

doctor, setup, run, ls, exec, rm, sweep.

Isolation

What is taken away from every sandbox.

API reference

Every option and method.