# Vue

Use the rupa-player custom element in Vue after telling the compiler it is a custom element.

## Quick start

1. Install the player.

   ```sh
   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):

   ```ts
   // 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:

   ```vue
   <script setup>
   import "@rupamotion/player/element";
   </script>

   <template>
   	<rupa-player src="/hero.rupaplay"></rupa-player>
   </template>
   ```

That's it: the animation plays.

## Need control?

The element's `player` is the player once the file is mounted (`null` before). A template `ref` is the element:

```vue
<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](/guides/control/) and [Events](/guides/events/).
