Skip to content
  1. Install the player.

    Terminal window
    npm i @rupamotion/player
  2. Put hero.rupaplay (export as Player file in Rupamotion) in public/.

  3. Import the element and use it in a component:

    import "@rupamotion/player/element";
    export function Hero() {
    return <rupa-player src="/hero.rupaplay"></rupa-player>;
    }

    For TypeScript, declare rupa-player in JSX.IntrinsicElements.

That’s it: the animation plays.

This demo loads a .rupaplay file: it plays once JavaScript runs.

The element’s player is the player once the file is mounted (null before). Keep the element in a variable with ref:

import "@rupamotion/player/element";
import type { RupaPlayerElement } from "@rupamotion/player/element";
export function Hero() {
let el!: RupaPlayerElement;
return (
<>
<rupa-player ref={el} src="/hero.rupaplay"></rupa-player>
<button onClick={() => el.player?.pause()}>Pause</button>
</>
);
}

See Control playback and Events.