---
name: example-vue
description: Patterns for using Helios with Vue. Use when building compositions in a Vue environment.
---
# Vue Composition Patterns
Integrate Helios into Vue components using the Composition API, Refs, and Watchers.
## Quick Start
### 1. Create `useVideoFrame` Composable
This composable subscribes to Helios and provides a reactive frame reference.
```javascript
// composables/useVideoFrame.js
import { ref, onUnmounted } from 'vue';
export function useVideoFrame(helios) {
const frame = ref(helios.currentFrame.peek());
const unsubscribe = helios.subscribe((state) => {
frame.value = state.currentFrame;
});
onUnmounted(() => {
unsubscribe();
});
return frame;
}
```
### 2. Create Composition Component
```vue
```
## Audio Visualization Pattern
For audio visualization, use a **computed property** to analyze audio data based on the reactive `frame` or `currentTime`.
### 1. Create Audio Analysis Composable
```javascript
// composables/useAudioData.js
import { computed, unref } from 'vue';
export function useAudioData(buffer, currentTime) {
return computed(() => {
const b = unref(buffer);
const t = unref(currentTime);
if (!b) return { rms: 0, waveform: [] };
const data = b.getChannelData(0);
const sampleRate = b.sampleRate;
const center = Math.floor(t * sampleRate);
// Analysis logic...
return { rms: 0.5, waveform: [] };
});
}
```
### 2. Use in Component
```vue
```
## Source Files
- Example: `examples/vue-canvas-animation/`
- Example: `examples/vue-audio-visualization/`