π₯ Make videos programmatically with React
Docs: Remotion on Vercel
JonnyBurger484d78aeeec8
diff --git a/packages/docs/docs/miscellaneous/vercel-functions.mdx b/packages/docs/docs/miscellaneous/vercel-functions.mdxdeleted file mode 100644index b42488f580..0000000000--- a/packages/docs/docs/miscellaneous/vercel-functions.mdx+++ /dev/null@@ -1,21 +0,0 @@-----image: /generated/articles-docs-miscellaneous-vercel-functions.png-sidebar_label: Vercel Functions-title: Can I render videos using Vercel Serverless functions?-crumb: 'FAQ'------It is currently not possible to render videos or stills on Vercel Serverless functions due to the 50MB maximum function size. Since Chromium is a dependency of Remotion, it alone almost entirely fills the quota available.--However, you can trigger a Remotion Lambda render through a Vercel Serverless function β our preferred choice for building applications. See our [Next template](https://github.com/remotion-dev/template-next) or [GitHub Unwrapped project](https://github.com/remotion-dev/github-unwrapped-2022) for an example of how to do so.--## Can I render videos in Next.js?--If you don't deploy to Vercel, it might be possible to render videos in API routes using the [server-side rendering](/docs/ssr) primitives.-Check if your provider has enough disk space for Chromium and Remotion and has sufficient CPU and RAM to render videos. See [this page](/docs/miscellaneous/nextjs#while-self-hosting-nextjs) for more details.--**Recommendation:**--If you plan to deploy to Vercel, we recommend to trigger Remotion Lambda renders from Vercel Serverless functions. See our [Next template](https://github.com/remotion-dev/template-next) or [GitHub Unwrapped 2022 project](https://github.com/remotion-dev/github-unwrapped-2022) for an example of how to do so.--If you plan to deploy to a server, [see here](http://localhost:3000/docs/miscellaneous/nextjs#while-self-hosting-nextjs).diff --git a/packages/docs/docs/miscellaneous/vercel.mdx b/packages/docs/docs/miscellaneous/vercel.mdxnew file mode 100644index 0000000000..1613583475--- /dev/null+++ b/packages/docs/docs/miscellaneous/vercel.mdx@@ -0,0 +1,113 @@+---+image: /generated/articles-docs-miscellaneous-vercel.png+sidebar_label: Vercel+title: Remotion on Vercel+crumb: 'Deployment'+---++Remotion integrates well with Vercel.++## Deployment++You can deploy any Remotion project on Vercel by connecting the repository and setting the following settings:++- **Build Command**: `bunx remotion bundle`+- **Output Directory**: `build`+- **Installation Command**: _Leave default_++## Client-side rendering++Enable [experimental client-side rendering](/docs/client-side-rendering) in your `remotion.config.ts` file:++```ts twoslash title="remotion.config.ts"+import {Config} from '@remotion/cli/config';+// ---cut---+Config.setExperimentalClientSideRenderingEnabled(true);+```++This will make it possible to render videos client-side on your Vercel deployment.++## Triggering Lambda renders from Vercel Serverless functions++You can trigger [Remotion Lambda renders](/docs/lambda) from Vercel Serverless functions.+See an example endpoint for rendering a video:++<details>+<summary>App router example</summary>++```ts twoslash title="src/app/api/lambda/render/route.ts"+import {AwsRegion, RenderMediaOnLambdaOutput} from '@remotion/lambda/client';+import {renderMediaOnLambda, speculateFunctionName} from '@remotion/lambda/client';+import {NextResponse} from 'next/server';++const DISK = 10240;+const RAM = 2048;+const REGION = 'eu-central-1';+const SITE_NAME = 'https://remotion-helloworld.vercel.app';+const TIMEOUT = 120;++export const POST = async (req: Request, res: NextResponse) => {+ if (!process.env.AWS_ACCESS_KEY_ID && !process.env.REMOTION_AWS_ACCESS_KEY_ID) {+ throw new TypeError('Set up Remotion Lambda to render videos. See the README.md for how to do so.');+ }+ if (!process.env.AWS_SECRET_ACCESS_KEY && !process.env.REMOTION_AWS_SECRET_ACCESS_KEY) {+ throw new TypeError('The environment variable REMOTION_AWS_SECRET_ACCESS_KEY is missing. Add it to your .env file.');+ }++ const body = await req.json();++ const result = await renderMediaOnLambda({+ codec: 'h264',+ functionName: speculateFunctionName({+ diskSizeInMb: DISK,+ memorySizeInMb: RAM,+ timeoutInSeconds: TIMEOUT,+ }),+ region: REGION as AwsRegion,+ serveUrl: SITE_NAME,+ composition: body.id,+ inputProps: body.inputProps,+ downloadBehavior: {+ type: 'download',+ fileName: 'video.mp4',+ },+ });++ return result;+};+```++</details>++See also:++- [App router - Example Render endpoint](https://github.com/remotion-dev/remotion/blob/main/packages/template-next-app-tailwind/src/app/api/lambda/render/route.ts)+- [App router - Example Progress endpoint](https://github.com/remotion-dev/remotion/blob/main/packages/template-next-app-tailwind/src/app/api/lambda/progress/route.ts)+- [Pages router - Example Render endpoint](https://github.com/remotion-dev/remotion/blob/main/packages/template-next-pages/src/pages/api/lambda/render.ts)+- [Pages router - Example Progress endpoint](https://github.com/remotion-dev/remotion/blob/main/packages/template-next-pages/src/pages/api/lambda/progress.ts)++## Rendering from a Vercel deployment++Deployments can be used as [Serve URLs](/docs/terminology/serve-url) to render videos using any [server-side rendering](/docs/ssr) primitive.++Example:++```bash+npx remotion render https://remotion-helloworld.vercel.app HelloWorld+```++## Rendering inside Vercel Functions++It is currently not possible to render videos or stills on Vercel Serverless functions due to the 50MB maximum function size. Since Chromium is a dependency of Remotion, it alone almost entirely fills the quota available.++We recommend you to resort to client-side rendering or Remotion Lambda.++## Next.js Templates++We currently offer 3 Next.js templates:++- [Next.js (App dir)](/templates/next)+- [Next.js (App dir + TailwindCSS)](/templates/next-tailwind)+- [Next.js (Pages router)](/templates/next-pages-dir)++These templates are recommended for building applications that can generate videos.diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.tsindex ba4ea0da94..f256d41a10 100644--- a/packages/docs/sidebars.ts+++ b/packages/docs/sidebars.ts@@ -1369,8 +1369,8 @@ const sidebars: SidebarsConfig = {items: ['miscellaneous/render-in-browser','miscellaneous/automatic-duration',- 'miscellaneous/vercel-functions','miscellaneous/nextjs',+ 'miscellaneous/vercel','miscellaneous/render-on-edge','miscellaneous/embed-studio','miscellaneous/absolute-paths',diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.tsindex f08ee9a160..a904e5ab5d 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -3836,13 +3836,13 @@ export const articles = [slug: 'typescript-aliases',},{- id: 'miscellaneous/vercel-functions',- title: 'Can I render videos using Vercel Serverless functions?',- relativePath: 'docs/miscellaneous/vercel-functions.mdx',- compId: 'articles-docs-miscellaneous-vercel-functions',- crumb: 'FAQ',+ id: 'miscellaneous/vercel',+ title: 'Remotion on Vercel',+ relativePath: 'docs/miscellaneous/vercel.mdx',+ compId: 'articles-docs-miscellaneous-vercel',+ crumb: 'Deployment',noAi: false,- slug: 'miscellaneous/vercel-functions',+ slug: 'miscellaneous/vercel',},{id: 'miscellaneous/video-formats',diff --git a/packages/docs/static/generated/articles-docs-miscellaneous-vercel-functions.png b/packages/docs/static/generated/articles-docs-miscellaneous-vercel-functions.pngdeleted file mode 100644index 36e3522ae0..0000000000Binary files a/packages/docs/static/generated/articles-docs-miscellaneous-vercel-functions.png and /dev/null differdiff --git a/packages/docs/static/generated/articles-docs-miscellaneous-vercel.png b/packages/docs/static/generated/articles-docs-miscellaneous-vercel.pngnew file mode 100644index 0000000000..a941e3bf6eBinary files /dev/null and b/packages/docs/static/generated/articles-docs-miscellaneous-vercel.png differdiff --git a/packages/docs/vercel.json b/packages/docs/vercel.jsonindex 3bd6fd8d0a..56e4c3b63d 100644--- a/packages/docs/vercel.json+++ b/packages/docs/vercel.json@@ -466,6 +466,11 @@"destination": "/docs/multiple-fps","permanent": false},+ {+ "source": "/docs/miscellaneous/vercel-functions",+ "destination": "/docs/miscellaneous/vercel",+ "permanent": false+ },{"source": "/system-prompt","destination": "/docs/ai/system-prompt",