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. Tell Vue that rupa-player is a custom element (compilerOptions.isCustomElement in the Vue plugin options of vite.config, see the Vue guide on web components):

    vite.config.ts
    import vue from "@vitejs/plugin-vue";
    import { defineConfig } from "vite";
    export default defineConfig({
    plugins: [vue({ template: { compilerOptions: { isCustomElement: (tag) => tag === "rupa-player" } } })],
    });
  4. Import the element and use it in a component:

    <script setup>
    import "@rupamotion/player/element";
    </script>
    <template>
    <rupa-player src="/hero.rupaplay"></rupa-player>
    </template>

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). A template ref is the element:

<script setup>
import "@rupamotion/player/element";
import { ref } from "vue";
const hero = ref(null);
</script>
<template>
<rupa-player ref="hero" src="/hero.rupaplay"></rupa-player>
<button @click="hero.player?.pause()">Pause</button>
</template>

See Control playback and Events.