Skip to content

RupaPlayer

Copy as Markdown

const RupaPlayer: (props) => ReactElement

A div the .rupaplay file src is mounted into, after the render (on a server it renders the div alone). Its ref is given the Player once the file is mounted, null before and after (player.root is the div, or the element of the file’s root class inside it). Unmounting destroys the player.

RupaPlayerProps & RefAttributes<Player<string>>

The file’s props and the div’s (see RupaPlayerProps); ref receives the Player.

ReactElement

The div.

import { useRef } from "react";
import type { Player } from "@rupamotion/player";
import { RupaPlayer } from "@rupamotion/player/react";
export function Hero() {
const player = useRef<Player>(null);
return (
<RupaPlayer
ref={player}
src="/hero.rupaplay"
markup="auto"
cloak
onReady={(ready) => ready.play("intro")}
onError={(error) => console.warn(error.code)}
/>
);
}