Installing Remotion in an existing project
Remotion can be installed into existing projects, such as Next.JS, Remix, Vite or Create React App, as well as server-only projects that run on Node.JS. Get started by adding the following packages:
- npm
- yarn
- pnpm
bashnpm i @remotion/cli remotion
bashnpm i @remotion/cli remotion
bashpnpm i @remotion/cli remotion
bashpnpm i @remotion/cli remotion
bashyarn add @remotion/cli remotion
bashyarn add @remotion/cli remotion
- If you'd like to embed a Remotion video in your existing React app, install
@remotion/playeras well. - If you'd like to render a video using the Node.JS APIs, install
@remotion/rendereras well. - If you'd like to trigger a render on Remotion Lambda, install
@remotion/lambdaas well.
Setting up the folder structure
Create a new folder for the Remotion files. It can be anywhere and assume any name, in this example we name it remotion and put it in the root of our project. Inside the folder you created, create 3 files:
remotion/Composition.tsxtsxexport constMyComposition = () => {return null;};
remotion/Composition.tsxtsxexport constMyComposition = () => {return null;};
remotion/Root.tsxtsximportReact from "react";import {Composition } from "remotion";import {MyComposition } from "./Composition";export constRemotionRoot :React .FC = () => {return (<><Composition id ="Empty"component ={MyComposition }durationInFrames ={60}fps ={30}width ={1280}height ={720}/></>);};
remotion/Root.tsxtsximportReact from "react";import {Composition } from "remotion";import {MyComposition } from "./Composition";export constRemotionRoot :React .FC = () => {return (<><Composition id ="Empty"component ={MyComposition }durationInFrames ={60}fps ={30}width ={1280}height ={720}/></>);};
remotion/index.tstsimport {registerRoot } from "remotion";import {RemotionRoot } from "./Root";registerRoot (RemotionRoot );
remotion/index.tstsimport {registerRoot } from "remotion";import {RemotionRoot } from "./Root";registerRoot (RemotionRoot );
The file that calls registerRoot() is now your Remotion entrypoint.
Starting the preview
Start the preview server using the following command:
npx remotion preview remotion/index.ts
npx remotion preview remotion/index.ts
Replace remotion/index.ts with your entrypoint if necessary.
Render a video
Render our a video using
npx remotion render remotion/index.ts MyComp out.mp4
npx remotion render remotion/index.ts MyComp out.mp4
Replace the entrypoint, composition name and output filename with the values that correspond to your usecase.
Install the ESLint Plugin
Remotion has an ESLint plugin that warns about improper usage of Remotion APIs. To add it to your existing project, install it:
- npm
- yarn
- pnpm
bashnpm i @remotion/eslint-plugin
bashnpm i @remotion/eslint-plugin
bashyarn add @remotion/eslint-plugin
bashyarn add @remotion/eslint-plugin
bashpnpm i @remotion/eslint-plugin
bashpnpm i @remotion/eslint-plugin
This snippet will enable the recommended rules only for the Remotion files:
.eslintrcjson{"plugins": ["@remotion"],"overrides": [{"files": ["remotion/*.{ts,tsx}"],"extends": ["plugin:@remotion/recommended"]}]}
.eslintrcjson{"plugins": ["@remotion"],"overrides": [{"files": ["remotion/*.{ts,tsx}"],"extends": ["plugin:@remotion/recommended"]}]}
Embed a Remotion video into your React app
You can use the <Player> component to display a Remotion video in your React project. Read the separate page about it for instructions.