Skip to content

🎥 Make videos programmatically with React

another new article

Jonny Burgerdf36822f13bc
diff --git a/.prettierrc.js b/.prettierrc.js
index 7129f6a51c..aba6cec450 100644
--- a/.prettierrc.js
+++ b/.prettierrc.js
@@ -1,14 +1,20 @@
module.exports = {
- singleQuote: true,
- bracketSpacing: false,
- useTabs: true,
- overrides: [
- {
- files: ["*.yml"],
- options: {
- singleQuote: false,
- },
- },
- ],
- plugins: [require.resolve("prettier-plugin-organize-imports")],
+ singleQuote: true,
+ bracketSpacing: false,
+ useTabs: true,
+ overrides: [
+ {
+ files: ['*.yml'],
+ options: {
+ singleQuote: false,
+ },
+ },
+ {
+ files: ['*.md', '*.mdx'],
+ options: {
+ useTabs: false,
+ },
+ },
+ ],
+ plugins: [require.resolve('prettier-plugin-organize-imports')],
};
diff --git a/packages/docs/.prettierignore b/packages/docs/.prettierignore
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/docs/components/InlineStep.tsx b/packages/docs/components/InlineStep.tsx
index c173242314..02777cbe1e 100644
--- a/packages/docs/components/InlineStep.tsx
+++ b/packages/docs/components/InlineStep.tsx
@@ -1,46 +1,50 @@
-import React from "react";
-import { RED } from "./layout/colors";
+import React from 'react';
+import {RED} from './layout/colors';
export const InlineStep: React.FC<{
- children: React.ReactNode;
- error?: boolean;
-}> = ({ children, error }) => {
- return (
- <div
- style={{
- backgroundColor: error ? RED : "var(--ifm-color-primary)",
- height: 24,
- width: 24,
- display: "inline-flex",
- color: "white",
- justifyContent: "center",
- alignItems: "center",
- borderRadius: 12,
- fontSize: 13,
- fontWeight: "bold",
- verticalAlign: "top",
- }}
- >
- {children}
- </div>
- );
+ readonly children: React.ReactNode;
+ readonly error?: boolean;
+}> = ({children, error}) => {
+ return (
+ <div
+ style={{
+ backgroundColor: error ? RED : 'var(--ifm-color-primary)',
+ height: 24,
+ width: 24,
+ display: 'inline-flex',
+ color: 'white',
+ justifyContent: 'center',
+ alignItems: 'center',
+ borderRadius: 12,
+ fontSize: 13,
+ fontWeight: 'bold',
+ verticalAlign: 'top',
+ }}
+ >
+ {children}
+ </div>
+ );
};
export const Step: React.FC<{
- children: React.ReactNode;
- error?: boolean;
-}> = ({ children, error }) => {
- return (
- <span
- style={{
- marginRight: 7,
- display: "inline-block",
- position: "relative",
- marginTop: 4,
- marginBottom: 4,
- }}
- >
- <InlineStep error={error}>{children}</InlineStep>{" "}
- </span>
- );
+ readonly children: React.ReactNode;
+ readonly error?: boolean;
+}> = ({children, error}) => {
+ return (
+ <a
+ id={children.toString()}
+ style={{
+ marginRight: 7,
+ display: 'inline-block',
+ position: 'relative',
+ marginTop: 4,
+ marginBottom: 4,
+ cursor: 'pointer',
+ textDecoration: 'none',
+ }}
+ href={`#${children.toString()}`}
+ >
+ <InlineStep error={error}>{children}</InlineStep>{' '}
+ </a>
+ );
};
diff --git a/packages/docs/components/Installation.tsx b/packages/docs/components/Installation.tsx
index fa979442cd..e8e169fdc6 100644
--- a/packages/docs/components/Installation.tsx
+++ b/packages/docs/components/Installation.tsx
@@ -1,100 +1,100 @@
-import React from "react";
+import React from 'react';
// @ts-expect-error
-import CodeBlock from "@theme/CodeBlock";
+import CodeBlock from '@theme/CodeBlock';
// @ts-expect-error
-import TabItem from "@theme/TabItem";
+import TabItem from '@theme/TabItem';
// @ts-expect-error
-import Tabs from "@theme/Tabs";
-import { VERSION } from "remotion";
+import Tabs from '@theme/Tabs';
+import {VERSION} from 'remotion';
const LightAndDark: React.FC<{
- readonly text: string;
-}> = ({ text }) => {
- return (
- <>
- <CodeBlock
- className="shiki github-light"
- language="bash"
- style={{
- backgroundColor: "rgb(255, 255, 255)",
- color: "rgb(36, 41, 47)",
- }}
- >
- <div className="code-container">
- <div className="line">{text}</div>
- </div>
- </CodeBlock>
- <CodeBlock
- className="shiki github-dark"
- language="bash"
- style={{
- backgroundColor: "rgb(13, 17, 23)",
- color: "rgb(201, 209, 217)",
- }}
- >
- <div className="code-container">
- <div className="line">{text}</div>
- </div>
- </CodeBlock>
- </>
- );
+ readonly text: string;
+}> = ({text}) => {
+ return (
+ <>
+ <CodeBlock
+ className="shiki github-light"
+ language="bash"
+ style={{
+ backgroundColor: 'rgb(255, 255, 255)',
+ color: 'rgb(36, 41, 47)',
+ }}
+ >
+ <div className="code-container">
+ <div className="line">{text}</div>
+ </div>
+ </CodeBlock>
+ <CodeBlock
+ className="shiki github-dark"
+ language="bash"
+ style={{
+ backgroundColor: 'rgb(13, 17, 23)',
+ color: 'rgb(201, 209, 217)',
+ }}
+ >
+ <div className="code-container">
+ <div className="line">{text}</div>
+ </div>
+ </CodeBlock>
+ </>
+ );
};
export const Installation: React.FC<{
- readonly pkg: string;
-}> = ({ pkg }) => {
- if (pkg === undefined) {
- throw new Error("pkg is undefined");
- }
+ readonly pkg: string;
+}> = ({pkg}) => {
+ if (pkg === undefined) {
+ throw new Error('pkg is undefined');
+ }
- const packages = pkg
- .split(" ")
- .map((p) => {
- if (p.startsWith("@remotion")) {
- return `${p}@${VERSION}`;
- }
+ const packages = pkg
+ .split(' ')
+ .map((p) => {
+ if (p.startsWith('@remotion') || p === 'remotion') {
+ return `${p}@${VERSION}`;
+ }
- return p;
- })
- .join(" ");
+ return p;
+ })
+ .join(' ');
- const isRemotionPackage = packages.includes("remotion");
+ const isRemotionPackage = packages.includes('remotion');
- return (
- <div>
- <Tabs
- defaultValue="npm"
- values={[
- { label: "npm", value: "npm" },
- { label: "yarn", value: "yarn" },
- { label: "pnpm", value: "pnpm" },
- { label: "bun", value: "bun" },
- ]}
- >
- <TabItem value="npm">
- <LightAndDark text={`npm i --save-exact ${packages}`} />
- </TabItem>
- <TabItem value="pnpm">
- <LightAndDark text={`pnpm i ${packages}`} />
- </TabItem>
- <TabItem value="bun">
- <LightAndDark text={`bun i ${packages}`} />
- </TabItem>
- <TabItem value="yarn">
- <LightAndDark text={`yarn --exact add ${packages}`} />
- </TabItem>
- </Tabs>
- {isRemotionPackage ? (
- <>
- This assumes you are currently using v{VERSION} of Remotion.
- <br />
- Also update <code>remotion</code> and all <code>`@remotion/*`</code>{" "}
- packages to the same version.
- <br />
- Remove all <code>^</code> character in front of the version numbers of
- it as it can lead to a version conflict.
- </>
- ) : null}
- </div>
- );
+ return (
+ <div>
+ <Tabs
+ defaultValue="npm"
+ values={[
+ {label: 'npm', value: 'npm'},
+ {label: 'yarn', value: 'yarn'},
+ {label: 'pnpm', value: 'pnpm'},
+ {label: 'bun', value: 'bun'},
+ ]}
+ >
+ <TabItem value="npm">
+ <LightAndDark text={`npm i --save-exact ${packages}`} />
+ </TabItem>
+ <TabItem value="pnpm">
+ <LightAndDark text={`pnpm i ${packages}`} />
+ </TabItem>
+ <TabItem value="bun">
+ <LightAndDark text={`bun i ${packages}`} />
+ </TabItem>
+ <TabItem value="yarn">
+ <LightAndDark text={`yarn --exact add ${packages}`} />
+ </TabItem>
+ </Tabs>
+ {isRemotionPackage ? (
+ <>
+ This assumes you are currently using v{VERSION} of Remotion.
+ <br />
+ Also update <code>remotion</code> and all <code>`@remotion/*`</code>{' '}
+ packages to the same version.
+ <br />
+ Remove all <code>^</code> character in front of the version numbers of
+ it as it can lead to a version conflict.
+ </>
+ ) : null}
+ </div>
+ );
};
diff --git a/packages/docs/docs/brownfield-installation.mdx b/packages/docs/docs/brownfield-installation.mdx
index edf44b8b55..69f00fb35b 100644
--- a/packages/docs/docs/brownfield-installation.mdx
+++ b/packages/docs/docs/brownfield-installation.mdx
@@ -3,7 +3,7 @@ image: /generated/articles-docs-brownfield-installation.png
id: brownfield
title: Installing Remotion in an existing project
sidebar_label: Installation in existing project
-crumb: "Brownfield integration"
+crumb: 'Brownfield integration'
---
import Tabs from '@theme/Tabs';
@@ -11,38 +11,7 @@ import TabItem from '@theme/TabItem';
Remotion can be installed into existing projects, such as [Next.JS](https://nextjs.org/), [Remix](https://remix.run/), [Vite](https://vitejs.dev/guide/) or [Create React App](https://create-react-app.dev/), as well as server-only projects that run on Node.JS. Get started by adding the following packages:
-<Tabs
-defaultValue="npm"
-values={[
-{ label: 'npm', value: 'npm', },
-{ label: 'yarn', value: 'yarn', },
-{ label: 'pnpm', value: 'pnpm', },
-]
-}>
-<TabItem value="npm">
-
-```bash
-npm i @remotion/cli remotion
-```
-
- </TabItem>
- <TabItem value="pnpm">
-
-```bash
-pnpm i @remotion/cli remotion
-```
-
- </TabItem>
-
- <TabItem value="yarn">
-
-```bash
-yarn add @remotion/cli remotion
-```
-
- </TabItem>
-
-</Tabs>
+<Installation pkg="remotion @remotion/cli" />
- If you'd like to embed a Remotion video in your existing React app, install [`@remotion/player`](/docs/player/installation) as well.
- If you'd like to render a video using the Node.JS APIs, install [`@remotion/renderer`](/docs/renderer) as well.
@@ -65,9 +34,9 @@ export const MyComposition: React.FC = () => {
};
// @filename: Root.tsx
// ---cut---
-import React from "react";
-import { Composition } from "remotion";
-import { MyComposition } from "./Composition";
+import React from 'react';
+import {Composition} from 'remotion';
+import {MyComposition} from './Composition';
export const RemotionRoot: React.FC = () => {
return (
@@ -117,7 +86,7 @@ import { RemotionRoot } from "./Root";
registerRoot(RemotionRoot);
```
-The file that calls [`registerRoot()`](/docs/register-root) is now your Remotion **entrypoint**.
+The file that calls [`registerRoot()`](/docs/register-root) is now your Remotion [**entry point**](/docs/terminology/entry-point).
:::note
Watch out for import aliases in your `tsconfig.json` that will resolve `import {...} from "remotion"` to the `remotion` folder. We recommend to not use `paths` without a prefix.
diff --git a/packages/docs/docs/player-into-remotion-project.mdx b/packages/docs/docs/player-into-remotion-project.mdx
new file mode 100644
index 0000000000..f72493fb90
--- /dev/null
+++ b/packages/docs/docs/player-into-remotion-project.mdx
@@ -0,0 +1,136 @@
+---
+id: player-into-remotion-project
+title: Turn a <Player> into a Remotion project
+crumb: 'Converting Remotion Projects'
+---
+
+If you have a React app that uses the [`<Player>`](/docs/player/player) component, you can turn it also into a Remotion project without having to create a new repository. This will enable you to:
+
+<Step>1</Step> Use the <a href="/docs/studio/">Remotion Studio</a>
+<br />
+<Step>2</Step> Render videos locally
+<br />
+<Step>2</Step> Create a <a href="/docs/terminology/bundle">
+ Remotion Bundle
+</a> that allows rendering in the cloud
+<br />
+
+## Instructions
+
+<Step>1</Step> Ensure that you don't already have a Studio installed - in the following
+templates, the Studio is already installed and can be started using the command <a href="/docs/cli/studio">
+ <code>npx remotion studio</code>
+</a>
+:<br />
+<br />
+
+- [Next.js (App dir)](/templates/next)
+- [Next.js (App dir + TailwindCSS)](/templates/next-tailwind)
+- [Next.js (Pages dir)](/templates/next-pages-dir)
+- [Remix](/templates/remix)
+
+<Step>2</Step> Install the Remotion CLI:
+
+<Installation pkg="@remotion/cli" />
+<br />
+
+<Step>3</Step> Make a new folder <code>remotion</code> and add these two files in
+it:
+<br />
+<br />
+
+```tsx twoslash title="remotion/Root.tsx"
+// @filename: Composition.tsx
+export const MyComposition: React.FC = () => {
+ return null;
+};
+// @filename: Root.tsx
+// ---cut---
+import React from 'react';
+import {Composition} from 'remotion';
+import {MyComposition} from './Composition';
+
+export const RemotionRoot: React.FC = () => {
+ return (
+ <>
+ <Composition
+ id="Empty"
+ // Import the component and add the properties you had in the `<Player>` before
+ component={MyComposition}
+ durationInFrames={60}
+ fps={30}
+ width={1280}
+ height={720}
+ />
+ </>
+ );
+};
+```
+
+```ts twoslash title="remotion/index.ts"
+// @filename: Composition.tsx
+export const MyComposition: React.FC = () => {
+ return null;
+};
+// @filename: Root.tsx
+import React from "react";
+import { Composition } from "remotion";
+import { MyComposition } from "./Composition";
+
+export const RemotionRoot: React.FC = () => {
+ return (
+ <>
+ <Composition
+ id="MyComp"
+ component={MyComposition}
+ durationInFrames={60}
+ fps={30}
+ width={1280}
+ height={720}
+ />
+ </>
+ );
+};
+// @filename: index.ts
+// ---cut---
+import { registerRoot } from "remotion";
+import { RemotionRoot } from "./Root";
+
+registerRoot(RemotionRoot);
+```
+
+Add the component you previously registered in the `<Player>` also to the `<Composition>`.
+If necessary, move the components into the <code>remotion</code> directory.
+
+The file that calls [`registerRoot()`](/docs/register-root) is now your Remotion [**entry point**](/docs/terminology/entry-point).
+
+<Step>4</Step> Apply common Webpack overrides that are commonly enabled in React
+apps:
+<br />
+<br />
+
+- [TailwindCSS](/docs/tailwind/tailwind)
+- [SCSS](/docs/enable-scss/overview)
+- [TypeScript Aliases](/docs/typescript-aliases#automatically-syncing-webpack-and-typescript-aliases)
+
+## Start the Remotion Studio:
+
+```
+npx remotion studio
+```
+
+## Render a video
+
+Render our a video using
+
+```
+npx remotion render remotion/index.ts
+```
+
+## Set up server-side rendering
+
+See [server-side rendering](/docs/ssr) for more information.
+
+## How do I download a video from the Remotion Player?
+
+The video first needs to get rendered - this can only be done on the server. See [ways to render](/docs/render) and [server-side rendering](/docs/ssr) for more information.
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index be8149fc58..77bff4afbe 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -776,6 +776,7 @@ module.exports = {
items: [
'brownfield',
'studio-into-app',
+ 'player-into-remotion-project',
'video-uploads',
'presigned-urls',
'font-picker',
diff --git a/packages/docs/src/css/custom.css b/packages/docs/src/css/custom.css
index 12c9686473..80b202d5a0 100644
--- a/packages/docs/src/css/custom.css
+++ b/packages/docs/src/css/custom.css
@@ -16,6 +16,10 @@
-moz-osx-font-smoothing: grayscale; /* Firefox */
}
+html {
+ scroll-padding-top: 80px;
+}
+
h1,
h2,
h3,