Vercel Sandbox

Vercel Sandbox via @vercel/sandbox — exec-emulation, native ports, and a filesystem that is auto-snapshotted on stop. No code interpreter.

Installation

@vercel/sandbox is an optional peer dependency of sbox-sdk, loaded lazily on first use.

pnpm add sbox-sdk @vercel/sandbox

Usage

import { createSandboxClient } from "sbox-sdk";
import { vercel } from "sbox-sdk/vercel";

const client = createSandboxClient({
  provider: vercel({
    token: process.env.VERCEL_TOKEN!,
    teamId: process.env.VERCEL_TEAM_ID!,
    projectId: process.env.VERCEL_PROJECT_ID!,
  }),
});

const sandbox = await client.create({ template: "node22", ports: [3000] });
const preview = await sandbox.ports.expose(3000);
console.log(preview.url);

template maps to Vercel's runtime selector (e.g. "node22"), not an arbitrary image. Vercel has no code interpreter, so sandbox.code is undefined.

Authentication

An access token plus the team and project ids.

Authentication variables for the vercel adapter.
OptionEnv varRequiredDescription
tokenVERCEL_TOKENrequiredVercel access token, or an OIDC token.
teamIdVERCEL_TEAM_IDrequiredThe team that owns the project.
projectIdVERCEL_PROJECT_IDrequiredThe project to associate sandboxes with.

When running on Vercel, the @vercel/sandbox SDK can resolve these from the standard environment (e.g. VERCEL_OIDC_TOKEN) automatically — pass them explicitly anywhere else.

Options

Prop

Type

Capabilities

CapabilityLevelNotes
background / streamingnative
filesUploadnative
exposePortnativepreview via declared ports
list / stop / pause / setTimeoutunsupported
killProcessunsupported
codeInterpreter / statefulKernelunsupportedsandbox.code is undefined
snapshot / forkunsupported

preservesDiskOnStop is truestop() auto-snapshots the filesystem. previewModel is declaredPorts.

On this page