Skip to content

🎥 Make videos programmatically with React

`@remotion/vercel`: Accept Sandbox instead of VercelSandbox in saveSnapshot, render, and upload APIs

Jonny Burger2a5bba0521f9
diff --git a/packages/docs/docs/vercel/render-still-on-vercel.mdx b/packages/docs/docs/vercel/render-still-on-vercel.mdx
index e303992763..9e86515d33 100644
--- a/packages/docs/docs/vercel/render-still-on-vercel.mdx
+++ b/packages/docs/docs/vercel/render-still-on-vercel.mdx
@@ -32,7 +32,7 @@ An object with the following properties:
### `sandbox`
-A `VercelSandbox` instance.
+A [`Sandbox`](https://vercel.com/docs/vercel-sandbox/sdk-reference#sandbox-class) instance.
### `compositionId`
diff --git a/packages/docs/docs/vercel/render-video-on-vercel.mdx b/packages/docs/docs/vercel/render-video-on-vercel.mdx
index 5ba593cf28..c0810f218c 100644
--- a/packages/docs/docs/vercel/render-video-on-vercel.mdx
+++ b/packages/docs/docs/vercel/render-video-on-vercel.mdx
@@ -36,7 +36,7 @@ An object with the following properties:
### `sandbox`
-A `VercelSandbox` instance.
+A [`Sandbox`](https://vercel.com/docs/vercel-sandbox/sdk-reference#sandbox-class) instance.
### `compositionId`
diff --git a/packages/docs/docs/vercel/save-snapshot.mdx b/packages/docs/docs/vercel/save-snapshot.mdx
index 5c311eb1cc..c7400cae4e 100644
--- a/packages/docs/docs/vercel/save-snapshot.mdx
+++ b/packages/docs/docs/vercel/save-snapshot.mdx
@@ -28,7 +28,7 @@ An object with the following properties:
### `sandbox`
-A `VercelSandbox` instance, typically obtained from [`createSandbox()`](/docs/vercel/create-sandbox).
+A [`Sandbox`](https://vercel.com/docs/vercel-sandbox/sdk-reference#sandbox-class) instance, typically obtained from [`createSandbox()`](/docs/vercel/create-sandbox).
### `expiration?`
diff --git a/packages/docs/docs/vercel/upload-to-blob-storage.mdx b/packages/docs/docs/vercel/upload-to-blob-storage.mdx
deleted file mode 100644
index 2bf14e8ec8..0000000000
--- a/packages/docs/docs/vercel/upload-to-blob-storage.mdx
+++ /dev/null
@@ -1,69 +0,0 @@
----
-image: /generated/articles-docs-vercel-upload-to-blob-storage.png
-title: uploadToBlobStorage()
-crumb: '@remotion/vercel'
----
-
-# uploadToBlobStorage()<AvailableFrom v="4.0.425" />
-
-Uploads a file from the sandbox to [Vercel Blob](https://vercel.com/docs/storage/vercel-blob) storage. Typically used after [`renderVideoOnVercel()`](/docs/vercel/render-video-on-vercel) or [`renderStillOnVercel()`](/docs/vercel/render-still-on-vercel) to make the output publicly accessible.
-
-## Example
-
-```ts twoslash title="route.ts"
-// @module: es2022
-// @target: es2022
-import {uploadToBlobStorage, createSandbox} from '@remotion/vercel';
-const sandbox = await createSandbox({bundleDir: '.remotion'});
-// ---cut---
-const {url, size} = await uploadToBlobStorage({
- sandbox,
- sandboxFilePath: '/tmp/video.mp4',
- contentType: 'video/mp4',
- blobToken: process.env.BLOB_READ_WRITE_TOKEN!,
-});
-
-console.log(`Uploaded ${size} bytes to ${url}`);
-```
-
-## Arguments
-
-An object with the following properties:
-
-### `sandbox`
-
-A `VercelSandbox` instance.
-
-### `sandboxFilePath`
-
-The path to the file inside the sandbox to upload, e.g. `"/tmp/video.mp4"`.
-
-### `blobPath?`
-
-The destination path in Vercel Blob, e.g. `"renders/abc.mp4"`. If omitted, a random path is generated.
-
-### `contentType`
-
-The MIME type of the file, e.g. `"video/mp4"` or `"image/png"`.
-
-### `blobToken`
-
-Your Vercel Blob read/write token. Typically `process.env.BLOB_READ_WRITE_TOKEN`.
-
-## Return value
-
-An object containing:
-
-### `url`
-
-The public download URL of the uploaded file.
-
-### `size`
-
-The size of the uploaded file in bytes.
-
-## See also
-
-- [`renderVideoOnVercel()`](/docs/vercel/render-video-on-vercel)
-- [`renderStillOnVercel()`](/docs/vercel/render-still-on-vercel)
-- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/vercel/src/upload-to-blob-storage.ts)
diff --git a/packages/docs/docs/vercel/upload-to-vercel-blob.mdx b/packages/docs/docs/vercel/upload-to-vercel-blob.mdx
index 50ee386fe1..0a418a1a1d 100644
--- a/packages/docs/docs/vercel/upload-to-vercel-blob.mdx
+++ b/packages/docs/docs/vercel/upload-to-vercel-blob.mdx
@@ -32,7 +32,7 @@ An object with the following properties:
### `sandbox`
-A `VercelSandbox` instance.
+A [`Sandbox`](https://vercel.com/docs/vercel-sandbox/sdk-reference#sandbox-class) instance.
### `sandboxFilePath`
diff --git a/packages/vercel/src/render-still-on-vercel.ts b/packages/vercel/src/render-still-on-vercel.ts
index 0f3c7b6a95..adc7df8082 100644
--- a/packages/vercel/src/render-still-on-vercel.ts
+++ b/packages/vercel/src/render-still-on-vercel.ts
@@ -1,5 +1,6 @@
+import type {Sandbox} from '@vercel/sandbox';
import {getRenderStillScript} from './internals/render-still-script';
-import type {RenderOnVercelProgress, VercelSandbox} from './types';
+import type {RenderOnVercelProgress} from './types';
export async function renderStillOnVercel({
sandbox,
@@ -10,7 +11,7 @@ export async function renderStillOnVercel({
onProgress,
bundleDir = '.remotion',
}: {
- sandbox: VercelSandbox;
+ sandbox: Sandbox;
compositionId: string;
inputProps: Record<string, unknown>;
imageFormat?: 'png' | 'jpeg' | 'webp';
diff --git a/packages/vercel/src/render-video-on-vercel.ts b/packages/vercel/src/render-video-on-vercel.ts
index 9d073b0597..cd9142fc0b 100644
--- a/packages/vercel/src/render-video-on-vercel.ts
+++ b/packages/vercel/src/render-video-on-vercel.ts
@@ -1,5 +1,6 @@
+import type {Sandbox} from '@vercel/sandbox';
import {getRenderVideoScript} from './internals/render-video-script';
-import type {RenderOnVercelProgress, VercelSandbox} from './types';
+import type {RenderOnVercelProgress} from './types';
export async function renderVideoOnVercel({
sandbox,
@@ -10,7 +11,7 @@ export async function renderVideoOnVercel({
onProgress,
bundleDir = '.remotion',
}: {
- sandbox: VercelSandbox;
+ sandbox: Sandbox;
compositionId: string;
inputProps: Record<string, unknown>;
codec?: string;
diff --git a/packages/vercel/src/save-snapshot.ts b/packages/vercel/src/save-snapshot.ts
index 2624b728c7..3bdcd86f21 100644
--- a/packages/vercel/src/save-snapshot.ts
+++ b/packages/vercel/src/save-snapshot.ts
@@ -1,5 +1,5 @@
import {put} from '@vercel/blob';
-import type {VercelSandbox} from './types';
+import type {Sandbox} from '@vercel/sandbox';
type SnapshotCache = {
snapshotId: string;
@@ -12,7 +12,7 @@ export async function saveSnapshot({
sandbox,
expiration = 0,
}: {
- sandbox: VercelSandbox;
+ sandbox: Sandbox;
expiration?: number;
}): Promise<{snapshotId: string}> {
const snapshot = await sandbox.snapshot({expiration});
diff --git a/packages/vercel/src/upload-to-vercel-blob.ts b/packages/vercel/src/upload-to-vercel-blob.ts
index 8183eba68a..d446a50246 100644
--- a/packages/vercel/src/upload-to-vercel-blob.ts
+++ b/packages/vercel/src/upload-to-vercel-blob.ts
@@ -1,4 +1,4 @@
-import type {VercelSandbox} from './types';
+import type {Sandbox} from '@vercel/sandbox';
function getExtension(filePath: string): string {
const lastDot = filePath.lastIndexOf('.');
@@ -52,7 +52,7 @@ export async function uploadToVercelBlob({
contentType,
blobToken,
}: {
- sandbox: VercelSandbox;
+ sandbox: Sandbox;
sandboxFilePath: string;
blobPath?: string;
contentType: string;