🎥 Make videos programmatically with React
Docs: Using @remotion/renderer in Next.js
Jonny Burger657860f0ecfc
diff --git a/packages/docs/docs/miscellaneous/nextjs.mdx b/packages/docs/docs/miscellaneous/nextjs.mdxnew file mode 100644index 0000000000..ad32117083--- /dev/null+++ b/packages/docs/docs/miscellaneous/nextjs.mdx@@ -0,0 +1,40 @@+---+image: /generated/articles-docs-miscellaneous-nextjs.png+sidebar_label: Rendering in Next.js+title: Using @remotion/renderer in Next.js+crumb: 'FAQ'+---++The [`@remotion/renderer`](/docs/renderer) package has dependencies on a headless browser and FFmpeg, which makes using it in Next.js a bit tricky.++## While deploying to Vercel++Since Remotion requires a headless browser, it is not currently possible to deploy the renderer to+Vercel, since the headless browser does not fit in the maximum function size.++**Recommendation**: Use [Remotion Lambda](/docs/lambda) for serverless workflows on Vercel.++## While self-hosting Next.js++If you are not deploying to Vercel and are sure that you are not running into function size limits, you may be able to use the renderer in Next.js (not officially supported).++```js title="next.config.js"+/** @type {import('next').NextConfig} */+const nextConfig = {+ reactStrictMode: true,+ serverExternalPackages: ['@remotion/renderer'],+};++module.exports = nextConfig;+```++Also be aware of the following:++- You cannot use `@remotion/bundler` inside an API route, because it includes Webpack, and it's not possible to bundle Webpack with Webpack.+ Instead, use `@remotion/bundler` to create a bundle outside the API route and then use the resulting folder in your API route.++- The `@remotion/renderer` package requires an FFmpeg binary from `node_modules`. Because an API route is being bundled, you might need to override the Webpack configuration to ensure the `remotion` binary is being included in it.++## See also++- [Can I render videos using Vercel Serverless functions?](/docs/miscellaneous/vercel-functions)diff --git a/packages/docs/docs/miscellaneous/vercel-functions.mdx b/packages/docs/docs/miscellaneous/vercel-functions.mdxindex 4e2d279e35..b42488f580 100644--- a/packages/docs/docs/miscellaneous/vercel-functions.mdx+++ b/packages/docs/docs/miscellaneous/vercel-functions.mdx@@ -1,8 +1,8 @@---image: /generated/articles-docs-miscellaneous-vercel-functions.png-sidebar_label: Vercel Functions / Next.js+sidebar_label: Vercel Functionstitle: Can I render videos using Vercel Serverless functions?-crumb: "FAQ"+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.@@ -12,15 +12,10 @@ However, you can trigger a Remotion Lambda render through a Vercel Serverless fu## 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.--⚠️ You need to be aware of the following:--- You cannot use `@remotion/bundler` inside an API route, because it includes Webpack, and the API route itself is being bundled with Webpack. It is not possible to bundle Webpack with Webpack. Instead, use `@remotion/bundler` to create a bundle outside the API route and then use the resulting folder in your API route.-- The `@remotion/renderer` package requires an FFmpeg binary from `node_modules`. Because an API route is being bundled, you might need to override the Webpack configuration to ensure the `remotion` binary is being included in it.-- Error have been reported with the Next.js App Router because the `remotion` package exports client-side components. Those are false positives because no React components are being rendered.+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 project](https://github.com/remotion-dev/github-unwrapped-2022) for an example of how to do so.-- If you plan to deploy to a [long-running server, we recommend rendering in a pure Node.js environment](/docs/ssr-node) outside of Next.js API routes to avoid the complications of bundling server-side code.+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/sidebars.js b/packages/docs/sidebars.jsindex c5901fd305..06518c06ea 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -1230,6 +1230,7 @@ module.exports = {'miscellaneous/render-in-browser','miscellaneous/automatic-duration','miscellaneous/vercel-functions',+ 'miscellaneous/nextjs','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 8aef28ed0a..1c18ce9f65 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -3104,6 +3104,15 @@ export const articles = [noAi: false,slug: 'miscellaneous/live-streaming',},+ {+ id: 'miscellaneous/nextjs',+ title: 'Using @remotion/renderer in Next.js',+ relativePath: 'docs/miscellaneous/nextjs.mdx',+ compId: 'articles-docs-miscellaneous-nextjs',+ crumb: 'FAQ',+ noAi: false,+ slug: 'miscellaneous/nextjs',+ },{id: 'miscellaneous/parse-media-vs-get-video-metadata',title: 'parseMedia() vs. getVideoMetadata()',diff --git a/packages/docs/static/generated/articles-docs-miscellaneous-nextjs.png b/packages/docs/static/generated/articles-docs-miscellaneous-nextjs.pngnew file mode 100644index 0000000000..a87523bc63Binary files /dev/null and b/packages/docs/static/generated/articles-docs-miscellaneous-nextjs.png differ