packages/docs/docs/vercel/create-sandbox.mdx
:::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.
// @module: es2022
// @target: es2022
import {addBundleToSandbox, createSandbox} from '@remotion/vercel';
import type {CreateSandboxOnProgress} from '@remotion/vercel';
// ---cut---
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();
An object with the following properties:
onProgress?A callback that receives progress updates during sandbox creation.
import type {CreateSandboxOnProgress} from '@remotion/vercel';
// ---cut---
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.
// @module: es2022
// @target: es2022
import {createSandbox} from '@remotion/vercel';
// ---cut---
const sandbox = await createSandbox({
resources: {vcpus: 8},
});
Default: {vcpus: 4}.
timeoutInMilliseconds?<AvailableFrom v="4.0.452" />The maximum time allowed for the sandbox to be created, in milliseconds. If exceeded, sandbox creation is aborted.
Default: 300000 (5 minutes).
A VercelSandbox object (a Sandbox with AsyncDisposable support).
When you are done with the sandbox, you need to stop it to free resources. There are two ways to do this:
sandbox.stop()Manually call sandbox.stop() when you are done:
// @module: es2022
// @target: es2022
import {createSandbox} from '@remotion/vercel';
// ---cut---
const sandbox = await createSandbox();
// ... use the sandbox
await sandbox.stop();
await usingUse await using to automatically stop the sandbox when it goes out of scope:
// @module: es2022
// @target: es2022
import {createSandbox} from '@remotion/vercel';
// ---cut---
await using sandbox = await createSandbox();
// ... use the sandbox
// sandbox.stop() is called automatically