Skip to content

🎥 Make videos programmatically with React

Cloudflare R2 support

Jonny Burgerd750d6fd5c8a
diff --git a/packages/docs/docs/lambda/custom-destination.mdx b/packages/docs/docs/lambda/custom-destination.mdx
index f61ac5b5b9..46ce4ae8a2 100644
--- a/packages/docs/docs/lambda/custom-destination.mdx
+++ b/packages/docs/docs/lambda/custom-destination.mdx
@@ -59,7 +59,7 @@ _Available from v3.2.23_
You can upload the file to another S3-compatible provider.
-- List of supported providers (non-exhaustive): [Supabase](/docs/lambda/supabase), Cloudflare, DigitalOcean Spaces
+- List of working providers (non-exhaustive): [Supabase](/docs/lambda/supabase), [Cloudflare](/docs/lambda/r2), DigitalOcean Spaces
- List of unsupported providers (non-exhaustive): Azure Blob Storage (not S3 compatible)
You must pass an `outName` [as specified above](#customizing-the-output-bucket) and also provide an `s3OutputProvider` like in the example below.
diff --git a/packages/docs/docs/lambda/r2.mdx b/packages/docs/docs/lambda/r2.mdx
new file mode 100644
index 0000000000..3d5d381e78
--- /dev/null
+++ b/packages/docs/docs/lambda/r2.mdx
@@ -0,0 +1,48 @@
+---
+image: /generated/articles-docs-lambda-r2.png
+id: r2
+title: Using Remotion Lambda with R2
+sidebar_label: Cloudflare R2
+slug: /lambda/r2
+---
+
+R2 by Cloudflare is a popular way to store renders because there are no egress fees.
+
+Create a Cloudflare bucket and set up an API key with **Object Read & Write** permissions.
+
+Use an [`s3OutputProvider`](/docs/lambda/custom-destination#saving-to-another-cloud) to store the rendered video in R2:
+
+```tsx twoslash
+import {renderMediaOnLambda, speculateFunctionName} from '@remotion/lambda/client';
+
+// ---cut---
+const {bucketName, renderId, cloudWatchMainLogs} = await renderMediaOnLambda({
+ serveUrl: 'https://remotion-helloworld.vercel.app',
+ // FIXME: Add your function specs here
+ functionName: speculateFunctionName({
+ diskSizeInMb: 2048,
+ memorySizeInMb: 2048,
+ timeoutInSeconds: 120,
+ }),
+ composition: 'HelloWorld',
+ region: 'eu-central-1',
+ codec: 'h264',
+ outName: {
+ // FIXME: Use the bucket name from your Cloudflare Storage settings
+ bucketName: 'remotion-test-bucket',
+ key: 'out.mp4',
+ s3OutputProvider: {
+ // FIXME: Use the endpoint from your Cloudflare Storage settings
+ endpoint: 'https://2fe488b3b0f4deee223aef7464784c46.r2.cloudflarestorage.com',
+ // FIXME: Use the Access Key from your Cloudflare settings
+ accessKeyId: process.env.R2_ACCESS_KEY_ID ?? '',
+ // FIXME: Use the Secret Access Key from your Cloudflare settings
+ secretAccessKey: process.env.R2_SECRET_ACCESS_KEY ?? '',
+ },
+ },
+});
+```
+
+## See also
+
+- [Using Remotion Lambda with Supabase](/lambda/supabase)
diff --git a/packages/docs/docs/lambda/supabase.mdx b/packages/docs/docs/lambda/supabase.mdx
index 56b00d8ac4..d2f117a14c 100644
--- a/packages/docs/docs/lambda/supabase.mdx
+++ b/packages/docs/docs/lambda/supabase.mdx
@@ -100,3 +100,7 @@ const {bucketName, renderId, cloudWatchMainLogs} = await renderMediaOnLambda({
},
});
```
+
+## See also
+
+- [Using Remotion Lambda with R2](/lambda/r2)
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index 0279898c82..afaafb0eb2 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -875,6 +875,7 @@ module.exports = {
'lambda/ruby',
'lambda/serverless-framework-integration',
'lambda/supabase',
+ 'lambda/r2',
'lambda/insights',
'lambda/multiple-buckets',
'lambda/how-lambda-works',
diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.ts
index 0a2e520ebd..7a91dbfe99 100644
--- a/packages/docs/src/data/articles.ts
+++ b/packages/docs/src/data/articles.ts
@@ -1952,6 +1952,15 @@ export const articles = [
noAi: false,
slug: 'lambda/python',
},
+ {
+ id: 'r2',
+ title: 'Using Remotion Lambda with R2',
+ relativePath: 'docs/lambda/r2.mdx',
+ compId: 'articles-docs-lambda-r2',
+ crumb: null,
+ noAi: false,
+ slug: 'lambda/r2',
+ },
{
id: 'region-selection',
title: 'Region selection',
diff --git a/packages/docs/static/generated/articles-docs-lambda-r2.png b/packages/docs/static/generated/articles-docs-lambda-r2.png
new file mode 100644
index 0000000000..c96b29864a
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-lambda-r2.png differ