Nuxt
Copy as MarkdownQuick start
Section titled “Quick start”-
Install the player.
Terminal window npm i @rupamotion/player -
Put
hero.rupaplay(export as Player file in Rupamotion) inpublic/. -
Mark
rupa-playeras a custom element innuxt.config(vue.compilerOptions.isCustomElement):nuxt.config.ts export default defineNuxtConfig({vue: { compilerOptions: { isCustomElement: (tag) => tag === "rupa-player" } },}); -
Load the element in
onMountedand use it in a component. The element loads in the browser only:<script setup>onMounted(() => 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.
Need control?
Section titled “Need control?”The element’s player is the player once the file is mounted (null before). A template ref is the element:
<script setup>const hero = ref(null);onMounted(() => import("@rupamotion/player/element"));</script>
<template> <rupa-player ref="hero" src="/hero.rupaplay"></rupa-player> <button @click="hero?.player?.pause()">Pause</button></template>See Control playback and Events.