Performance: Vue components in Astro
Using Vue components in Astro affects page load speed and interaction responsiveness by adding client-side JavaScript and hydration costs.
--- import MyVueComponent from '../components/MyVueComponent.vue'; --- <MyVueComponent client:idle />
--- import MyVueComponent from '../components/MyVueComponent.vue'; --- <MyVueComponent client:load />
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| client:load hydration | Hydrates full component DOM | Triggers 1 reflow per component | Moderate paint cost due to JS execution | [X] Bad |
| client:idle hydration | Hydrates component DOM after idle | Single reflow delayed | Lower paint cost, less blocking | [OK] Good |
MyButton.vue inside an Astro file?import MyButton from './MyButton.vue'; to import the component.client:load tells Astro to load the Vue component on page load, enabling interactivity.---
import Counter from './Counter.vue';
---
Assuming Counter.vue shows a button that increments a number on click.client:load directive loads the Vue component on page load, enabling interactivity.---
import MyWidget from './MyWidget.vue';
---
Why does the component not behave interactively in the browser?client:load, Vue components render as static HTML with no interactivity.import LazyWidget from './LazyWidget.vue';
Choose the correct usage:client:visible loads the component only when it scrolls into view, optimizing performance.client:idle loads when browser is idle, client:load loads immediately, and client:only='vue' loads only Vue but not lazily.Pass the test and this pattern moves unknown