Skip to main content

saveSnapshot()v4.0.425

Takes a snapshot of a sandbox and saves the snapshot ID to Vercel Blob storage, keyed by the current VERCEL_DEPLOYMENT_ID. This allows restoreSnapshot() to restore the sandbox in production without re-creating it.

Typically called during the build step (e.g. in create-snapshot.ts) to cache the sandbox for production use.

Example

const {snapshotId} = await saveSnapshot({sandbox});
console.log(`Snapshot saved: ${snapshotId}`);

Arguments

An object with the following properties:

sandbox

A Sandbox instance, typically obtained from createSandbox().

expiration?

The expiration time for the snapshot in seconds. Default: 0 (never expires).

Return value

An object containing:

snapshotId

A string identifier for the snapshot.

See also