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 ref:

import "@rupamotion/player/element";
import type { RupaPlayerElement } from "@rupamotion/player/element";
import { useRef } from "preact/hooks";
export function Hero() {
const el = useRef<RupaPlayerElement>(null);
return (
<>
<rupa-player ref={el} src="/hero.rupaplay"></rupa-player>
<button onClick={() => el.current?.player?.pause()}>Pause</button>
</>
);
}

See Control playback and Events.