Using Remotion in Angular
This guide explains how to integrate Remotion into an Angular project.
Install required packages
Install Remotion and necessary dependencies:
- npm
- pnpm
- yarn
- bun
Use npm as the package managerbash
Use pnpm as the package managerbash
Use Yarn as the package managerbash
Use Bun as the package manager and runtimebash
Bun as a runtime is mostly supported. Read more here.
Create a Remotion folder
For better separation, create a folder to hold your Remotion files:
plaintext
Copy the contents of your Remotion project or a starter template (e.g., HelloWorld) into this new folder. This will help separate Remotion related files from the rest of your Angular codebase.
Copy remotion.config.ts
Copy the remotion.config.ts file to the root directory of your Angular project, placing it at the same level as package.json.
This configuration file is necessary for Remotion to recognize and compile your project settings.
Configure TypeScript for JSX
To enable JSX support in Angular, update the tsconfig.json file by setting "jsx": "react" under compilerOptions. This configuration allows Angular to interpret JSX syntax used in Remotion's React components.
tsconfig.jsonjson
The "skipLibCheck": true setting is also recommended to prevent compatibility issues with certain library types.
Create a React wrapper component for Angular
To embed Remotion components in Angular, create a wrapper component:
- In your remotionfolder, create a file namedPlayerViewWrapper.tsx.
- Ensure each .tsxfile imports React explicitly at the top of the file:
PlayerViewWrapper.tsxtsx
This wrapper component will serve as the bridge between Angular and Remotion’s React components.
You can also pass an EventEmitter instead of a Signal.
Create a wrapper for the Remotion player
- In your remotionfolder, create a file namedPlayerView.tsx.
- Ensure each .tsxfile imports React explicitly at the top of the file:
This will get the reference to the player with createRef.
PlayerView.tsxtsx
Use the component in Angular
To display the Remotion player within an Angular template, add your new wrapper component wherever you'd like the player to appear:
html
This Angular component tag will render the Remotion Player, allowing you to pass data or configuration as needed through Angular's data binding.
You're now able to use the API of the player via this.playerRef().
