VueNuxtViteVueTips & Tricks

Curated collection of practical tips, tricks and best practices for building modern Vue applications.

Vue 3.5's `<Teleport defer>` waits until the current render cycle is complete, so you can teleport to a target rendered later in the same template.

<!-- Before (Vue 3.4) — this FAILS because #container doesn't exist yet -->
<template>
  <Teleport to="#container">
    <p>Teleported content</p>
  </Teleport>
  <div id="container"></div>
</template>
<!-- After (Vue 3.5+) — defer waits for the full render cycle -->
<template>
  <Teleport defer to="#container">
    <p>Teleported content</p>
  </Teleport>
  <div id="container"></div>
</template>