# Astro

Use the rupa-player custom element in an Astro page, with the script bundled once per page.

## Quick start

1. Install the player.

   ```sh
   npm i @rupamotion/player
   ```

2. Put `hero.rupaplay` (export as **Player file** in Rupamotion) in `public/`.

3. Use the element in a page or component. Astro bundles the script once per page:

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

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

That's it: the animation plays.

## Need control?

The element's `player` is the player once the file is mounted. Pause it from a button in the same script:

```astro
<rupa-player src="/hero.rupaplay"></rupa-player>
<button id="pause">Pause</button>

<script>
	import "@rupamotion/player/element";

	document.querySelector("#pause")?.addEventListener("click", () => {
		document.querySelector("rupa-player")?.player?.pause();
	});
</script>
```

See [Control playback](/guides/control/) and [Events](/guides/events/).
