Skip to content

🎥 Make videos programmatically with React

use vercel blob storage, update readme

umungobungof02a6c53c717
diff --git a/bun.lock b/bun.lock
index d3f6fa99ce..7e8bbc4f6a 100644
--- a/bun.lock
+++ b/bun.lock
@@ -2129,6 +2129,7 @@
"@remotion/player": "workspace:*",
"@remotion/shapes": "workspace:*",
"@remotion/tailwind-v4": "workspace:*",
+ "@vercel/blob": "^2.0.1",
"@vercel/sandbox": "^1.3.1",
"clsx": "2.1.1",
"next": "16.0.10",
@@ -3300,7 +3301,7 @@
"@mux/upchunk": ["@mux/[email protected]", "", { "dependencies": { "event-target-shim": "^6.0.2", "xhr": "^2.6.0" } }, "sha512-D+TtvlujlZQjh5I+vFzJ31h5E1uVpEaLdR8M3BNaCFbVLnFMZs8J/L/fYSUyVGnyHT/yDtPHn/IHKdo3G6oSjA=="],
- "@napi-rs/wasm-runtime": ["@napi-rs/[email protected]", "", { "dependencies": { "@emnapi/core": "^1.4.3", "@emnapi/runtime": "^1.4.3", "@tybys/wasm-util": "^0.10.0" } }, "sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ=="],
+ "@napi-rs/wasm-runtime": ["@napi-rs/[email protected]", "", { "dependencies": { "@emnapi/core": "^1.5.0", "@emnapi/runtime": "^1.5.0", "@tybys/wasm-util": "^0.10.1" } }, "sha512-SeDnOO0Tk7Okiq6DbXmmBODgOAb9dp9gjlphokTUxmt8U3liIP1ZsozBahH69j/RJv+Rfs6IwUKHTgQYJ/HBAw=="],
"@next/env": ["@next/[email protected]", "", {}, "sha512-CRSCPJiSZoi4Pn69RYBDI9R7YK2g59vLexPQFXY0eyw+ILevIenCywzg+DqmlBik9zszEnw2HLFOUlLAcJbL7g=="],
@@ -4656,6 +4657,8 @@
"@vanilla-extract/private": ["@vanilla-extract/[email protected]", "", {}, "sha512-gT2jbfZuaaCLrAxwXbRgIhGhcXbRZCG3v4TTUnjw0EJ7ArdBRxkq4msNJkbuRkCgfIK5ATmprB5t9ljvLeFDEA=="],
+ "@vercel/blob": ["@vercel/[email protected]", "", { "dependencies": { "async-retry": "^1.3.3", "is-buffer": "^2.0.5", "is-node-process": "^1.2.0", "throttleit": "^2.1.0", "undici": "^6.23.0" } }, "sha512-DeJmC/B5oH1ExazYh/UvjbN6Mg0q0wlDz29GPIPNhi4COjVzqYRkyPYjOcAZd+RgXVzWqGXholZWtGcLCPuL8A=="],
+
"@vercel/functions": ["@vercel/[email protected]", "", { "dependencies": { "@vercel/oidc": "3.1.0" }, "peerDependencies": { "@aws-sdk/credential-provider-web-identity": "*" }, "optionalPeers": ["@aws-sdk/credential-provider-web-identity"] }, "sha512-lKWDWEhFcpt/zL3ueWqII8W5BY73MC5WUuZyudditbbya6mP8jCLQEuXBxJetpEKgnEn+5xCyK962rw4v1RSVA=="],
"@vercel/oidc": ["@vercel/[email protected]", "", {}, "sha512-Fw28YZpRnA3cAHHDlkt7xQHiJ0fcL+NRcIqsocZQUSmbzeIKRpwttJjik5ZGanXP+vlA4SbTg+AbA3bP363l+w=="],
@@ -8672,8 +8675,6 @@
"@rollup/pluginutils/estree-walker": ["[email protected]", "", {}, "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="],
- "@rspack/binding-wasm32-wasi/@napi-rs/wasm-runtime": ["@napi-rs/[email protected]", "", { "dependencies": { "@emnapi/core": "^1.5.0", "@emnapi/runtime": "^1.5.0", "@tybys/wasm-util": "^0.10.1" } }, "sha512-SeDnOO0Tk7Okiq6DbXmmBODgOAb9dp9gjlphokTUxmt8U3liIP1ZsozBahH69j/RJv+Rfs6IwUKHTgQYJ/HBAw=="],
-
"@smithy/chunked-blob-reader/tslib": ["[email protected]", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
"@smithy/chunked-blob-reader-native/tslib": ["[email protected]", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
@@ -9106,6 +9107,8 @@
"@typescript-eslint/visitor-keys/eslint-visitor-keys": ["[email protected]", "", {}, "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="],
+ "@unrs/resolver-binding-wasm32-wasi/@napi-rs/wasm-runtime": ["@napi-rs/[email protected]", "", { "dependencies": { "@emnapi/core": "^1.4.3", "@emnapi/runtime": "^1.4.3", "@tybys/wasm-util": "^0.10.0" } }, "sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ=="],
+
"@vanilla-extract/babel-plugin-debug-ids/@babel/core": ["@babel/[email protected]", "", { "dependencies": { "@babel/code-frame": "^7.29.0", "@babel/generator": "^7.29.0", "@babel/helper-compilation-targets": "^7.28.6", "@babel/helper-module-transforms": "^7.28.6", "@babel/helpers": "^7.28.6", "@babel/parser": "^7.29.0", "@babel/template": "^7.28.6", "@babel/traverse": "^7.29.0", "@babel/types": "^7.29.0", "@jridgewell/remapping": "^2.3.5", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", "json5": "^2.2.3", "semver": "^6.3.1" } }, "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA=="],
"@vanilla-extract/css/lru-cache": ["[email protected]", "", {}, "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="],
@@ -9116,6 +9119,8 @@
"@vanilla-extract/integration/vite-node": ["[email protected]", "", { "dependencies": { "cac": "^6.7.14", "debug": "^4.3.4", "pathe": "^1.1.1", "picocolors": "^1.0.0", "vite": "^5.0.0" }, "bin": { "vite-node": "vite-node.mjs" } }, "sha512-YAXkfvGtuTzwWbDSACdJSg4A4DZiAqckWe90Zapc/sEX3XvHcw1NdurM/6od8J207tSDqNbSsgdCacBgvJKFuA=="],
+ "@vercel/blob/is-buffer": ["[email protected]", "", {}, "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ=="],
+
"@vercel/remix/isbot": ["[email protected]", "", {}, "sha512-vne1mzQUTR+qsMLeCBL9+/tgnDXRyc2pygLGl/WsgA+EZKIiB5Ehu0CiVTHIIk30zhJ24uGz4M5Ppse37aR0Hg=="],
"@vercel/sandbox/undici": ["[email protected]", "", {}, "sha512-MJZrkjyd7DeC+uPZh+5/YaMDxFiiEEaDgbUSVMXayofAkDWF1088CDo+2RPg7B1BuS1qf1vgNE7xqwPxE0DuSQ=="],
diff --git a/packages/template-vercel/README.md b/packages/template-vercel/README.md
index 3e2d2ec4fa..a6e6e5c4b7 100644
--- a/packages/template-vercel/README.md
+++ b/packages/template-vercel/README.md
@@ -4,7 +4,7 @@
This is a Next.js template for building programmatic video apps with [`@remotion/player`](https://remotion.dev/player) and rendering via [Vercel Sandbox](https://vercel.com/docs/functions/sandbox).
-This template uses the Next.js App directory with TailwindCSS. The rendering happens in a Vercel Sandbox environment, making it easy to deploy and scale on Vercel.
+This template uses the Next.js App directory with TailwindCSS. Videos are rendered in a Vercel Sandbox environment and stored in [Vercel Blob](https://vercel.com/docs/storage/vercel-blob) storage.
<img src="https://github.com/remotion-dev/template-next/assets/1629785/c9c2e5ca-2637-4ec8-8e40-a8feb5740d88" />
@@ -50,9 +50,71 @@ npx remotion upgrade
## Deploy to Vercel
-This template is designed to be deployed on Vercel. Simply connect your GitHub repository to Vercel and it will automatically deploy your app.
+### 1. Deploy your Remotion bundle
-The rendering happens via Vercel Sandbox, which provides an isolated environment for running Remotion renders.
+First, build and deploy your Remotion bundle:
+
+```bash
+npx remotion bundle
+cd build
+vercel deploy --prod
+```
+
+Copy the deployment URL (e.g., `https://my-bundle.vercel.app`).
+
+**Note:** The bundle must be publicly accessible (no Vercel Authentication) since the sandbox fetches it without credentials.
+
+### 2. Create a Vercel Blob store
+
+1. Go to your Vercel dashboard
+2. Navigate to Storage > Create > Blob
+3. Create a new Blob store and attach it to your project
+
+If you deploy your app to the same Vercel project where your Blob store is attached, the `BLOB_READ_WRITE_TOKEN` environment variable is automatically available.
+
+### 3. Set environment variables
+
+In your Vercel project settings, add:
+
+| Variable | Description |
+| -------------------- | ------------------------------------ |
+| `REMOTION_SERVE_URL` | URL of your deployed Remotion bundle |
+
+When deployed to Vercel, the `BLOB_READ_WRITE_TOKEN` is automatically available if your Blob store is attached to the same project. For local development, see below.
+
+### 4. Deploy
+
+Connect your GitHub repository to Vercel and it will automatically deploy your app.
+
+## Local Development
+
+To run renders locally, pull environment variables from Vercel:
+
+```bash
+vercel link # Link to your Vercel project (if not already linked)
+vercel env pull .env.local
+```
+
+This pulls `BLOB_READ_WRITE_TOKEN` from your attached Blob store. You'll also need to add `REMOTION_SERVE_URL` to `.env.local` manually:
+
+```
+REMOTION_SERVE_URL=https://your-bundle.vercel.app
+```
+
+Then start the dev server:
+
+```bash
+npm run dev
+```
+
+## How It Works
+
+1. User clicks "Render" in the browser
+2. API spawns a Vercel Sandbox (ephemeral Linux VM)
+3. Sandbox runs `renderMedia()` from `@remotion/renderer`
+4. Progress is streamed to the browser via Server-Sent Events
+5. Completed video is uploaded to Vercel Blob
+6. User receives the video URL
## Docs
diff --git a/packages/template-vercel/package.json b/packages/template-vercel/package.json
index 48881e6be9..30978d444d 100644
--- a/packages/template-vercel/package.json
+++ b/packages/template-vercel/package.json
@@ -22,6 +22,7 @@
"@remotion/player": "workspace:*",
"@remotion/shapes": "workspace:*",
"@remotion/tailwind-v4": "workspace:*",
+ "@vercel/blob": "^2.0.1",
"@vercel/sandbox": "^1.3.1",
"clsx": "2.1.1",
"next": "16.0.10",
diff --git a/packages/template-vercel/src/app/api/render/route.ts b/packages/template-vercel/src/app/api/render/route.ts
index 174d881996..452b2327c7 100644
--- a/packages/template-vercel/src/app/api/render/route.ts
+++ b/packages/template-vercel/src/app/api/render/route.ts
@@ -1,3 +1,4 @@
+import { put } from "@vercel/blob";
import { Sandbox } from "@vercel/sandbox";
import { RenderRequest } from "../../../../types/schema";
import {
@@ -201,7 +202,7 @@ export async function POST(req: Request) {
throw new Error(`Render failed: ${stderr || stdout}`);
}
- await send({ type: "phase", phase: "Reading output..." });
+ await send({ type: "phase", phase: "Uploading video..." });
const videoBuffer = await sandbox.readFileToBuffer({
path: "/tmp/video.mp4",
@@ -210,9 +211,15 @@ export async function POST(req: Request) {
throw new Error("Failed to read rendered video");
}
+ const renderId = crypto.randomUUID();
+ const blob = await put(`renders/${renderId}.mp4`, videoBuffer, {
+ access: "public",
+ contentType: "video/mp4",
+ });
+
await send({
type: "done",
- url: `data:video/mp4;base64,${videoBuffer.toString("base64")}`,
+ url: blob.url,
size: videoBuffer.length,
});
} catch (err) {