Skip to main content

createSandbox()v4.0.426

warning

Experimental package: We reserve the right to make breaking changes in order to correct bad design decisions until this notice is gone.

Creates a new Vercel Sandbox with all Remotion dependencies installed, including system libraries, the compositor, and a browser.
After creating the sandbox, call addBundleToSandbox() to copy your Remotion bundle into it.

Example​

create-snapshot.ts
const sandbox = await createSandbox({ onProgress: async ({progress, message}) => { console.log(`${message} (${Math.round(progress * 100)}%)`); }, }); await addBundleToSandbox({ sandbox, bundleDir: '/path/to/bundle', }); // ... use the sandbox await sandbox.stop();

Arguments​

An object with the following properties:

onProgress?​

A callback that receives progress updates during sandbox creation.

const onProgress: CreateSandboxOnProgress = async ({progress, message}) => {
  console.log(`${message} (${Math.round(progress * 100)}%)`);
};

resources?​

The resources to allocate to the sandbox. The type is inherited from the @vercel/sandbox SDK.

Each vCPU gets 2048 MB of memory.

custom-resources.ts
const sandbox = await createSandbox({ resources: {vcpus: 8}, });

Default: {vcpus: 4}.

timeoutInMilliseconds?v4.0.452​

The maximum time allowed for the sandbox to be created, in milliseconds. If exceeded, sandbox creation is aborted.

Default: 300000 (5 minutes).

Return value​

A VercelSandbox object (a Sandbox with AsyncDisposable support).

Stopping the sandbox​

When you are done with the sandbox, you need to stop it to free resources. There are two ways to do this:

Using sandbox.stop()​

Manually call sandbox.stop() when you are done:

manual-cleanup.ts
const sandbox = await createSandbox(); // ... use the sandbox await sandbox.stop();

Using await using​

Use await using to automatically stop the sandbox when it goes out of scope:

auto-cleanup.ts
await using sandbox = await createSandbox(); // ... use the sandbox // sandbox.stop() is called automatically

Compatibility​

ServersEnvironments
Node.js
Bun
Serverless Functions
Node.js runtime

See also​