Skip to content

πŸŽ₯ Make videos programmatically with React

docs: Troubleshooting article when using Next.js Image tag

Jonny Burger1e0728108b8c
diff --git a/packages/docs/docs/parametrized-rendering.md b/packages/docs/docs/parameterized-rendering.md
similarity index 97%
rename from packages/docs/docs/parametrized-rendering.md
rename to packages/docs/docs/parameterized-rendering.md
index 40b7d5006e..3498228b25 100644
--- a/packages/docs/docs/parametrized-rendering.md
+++ b/packages/docs/docs/parameterized-rendering.md
@@ -1,4 +1,5 @@
---
+image: /generated/articles-docs-parameterized-rendering.png
id: parameterized-rendering
title: Parameterized videos
sidebar_label: Passing props
diff --git a/packages/docs/docs/troubleshooting/background-image.md b/packages/docs/docs/troubleshooting/background-image.md
index aa63bc64ef..887a3918f5 100644
--- a/packages/docs/docs/troubleshooting/background-image.md
+++ b/packages/docs/docs/troubleshooting/background-image.md
@@ -55,3 +55,4 @@ const myMarkup = (
- [`<Img>`](/docs/img)
- [Flickering](/docs/flickering)
+- [Flickering with Next.js' Image tag](/docs/troubleshooting/nextjs-image)
diff --git a/packages/docs/docs/troubleshooting/nextjs-image.md b/packages/docs/docs/troubleshooting/nextjs-image.md
new file mode 100644
index 0000000000..4fdfb6b6c9
--- /dev/null
+++ b/packages/docs/docs/troubleshooting/nextjs-image.md
@@ -0,0 +1,38 @@
+---
+image: /generated/articles-docs-troubleshooting-nextjs-image.png
+sidebar_label: Flickering with Next.js Image
+title: Flickering when using Next.js <Image> tag
+crumb: "Common mistakes"
+---
+
+The following code is discouraged in Remotion:
+
+```tsx title="❌ Don't do this"
+import Image from "next/image";
+
+const myMarkup = <Image src="https://picsum.photos/200/300"></Image>;
+```
+
+## Problem
+
+Remotion has no way of knowing when the image is finished loading because it is impossible to determine so when loading an image through `<Image>`.
+
+This will lead to Remotion not waiting for the image to be loaded during rendering and cause visible flickers.
+
+## Solution
+
+Use the [`<Img>`](/docs/img) tag instead:
+
+```tsx twoslash title="βœ… Do this"
+const src = "abc";
+// ---cut---
+import { AbsoluteFill, Img } from "remotion";
+
+const myMarkup = <Img src="https://picsum.photos/200/300" />;
+```
+
+## See also
+
+- [`<Img>`](/docs/img)
+- [Flickering](/docs/flickering)
+- [Flickering with background-image](/docs/troubleshooting/background-image)
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index 02d21a2d8d..fa489f9dd5 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -523,6 +523,7 @@ module.exports = {
"staticfile-relative-paths",
"staticfile-remote-urls",
"troubleshooting/background-image",
+ "troubleshooting/nextjs-image",
"troubleshooting/rosetta",
"troubleshooting/loading-root-component",
"troubleshooting/defaultprops-too-big",
diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.ts
index fd3ce58c9c..f29b7713ee 100644
--- a/packages/docs/src/data/articles.ts
+++ b/packages/docs/src/data/articles.ts
@@ -2157,6 +2157,13 @@ export const articles = [
compId: "articles-docs-troubleshooting-loading-root-component",
crumb: "Troubleshooting",
},
+ {
+ id: "troubleshooting/nextjs-image",
+ title: "Flickering when using Next.js <Image> tag",
+ relativePath: "docs/troubleshooting/nextjs-image.md",
+ compId: "articles-docs-troubleshooting-nextjs-image",
+ crumb: "Common mistakes",
+ },
{
id: "rosetta",
title: "Apple Silicon under Rosetta",
diff --git a/packages/docs/static/generated/articles-docs-parameterized-rendering.png b/packages/docs/static/generated/articles-docs-parameterized-rendering.png
new file mode 100644
index 0000000000..4d6a3a3f45
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-parameterized-rendering.png differ
diff --git a/packages/docs/static/generated/articles-docs-parametrized-rendering.png b/packages/docs/static/generated/articles-docs-parametrized-rendering.png
deleted file mode 100644
index da707943c6..0000000000
Binary files a/packages/docs/static/generated/articles-docs-parametrized-rendering.png and /dev/null differ
diff --git a/packages/docs/static/generated/articles-docs-troubleshooting-nextjs-image.png b/packages/docs/static/generated/articles-docs-troubleshooting-nextjs-image.png
new file mode 100644
index 0000000000..869eb9d905
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-troubleshooting-nextjs-image.png differ