createSandbox()v4.0.426
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.tsconstsandbox = awaitcreateSandbox ({onProgress : async ({progress ,message }) => {console .log (`${message } (${Math .round (progress * 100)}%)`); }, }); awaitaddBundleToSandbox ({sandbox ,bundleDir : '/path/to/bundle', }); // ... use the sandbox awaitsandbox .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.tsconstsandbox = awaitcreateSandbox ({resources : {vcpus : 8}, });
Default: {vcpus: 4}.
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.tsconstsandbox = awaitcreateSandbox (); // ... use the sandbox awaitsandbox .stop ();
Using await using
Use await using to automatically stop the sandbox when it goes out of scope:
auto-cleanup.tsawait usingsandbox = awaitcreateSandbox (); // ... use the sandbox // sandbox.stop() is called automatically