Vue3 Fundamentals ยท Modern Vue (3.5 / 3.6)

Vapor Mode

Vapor Mode

Every Vue component today renders through the virtual DOM: the template builds a tree of lightweight objects, Vue compares it with the previous tree, and only the differences reach the real DOM. That comparison is fast, but the compiler already knows the shape of the template.

Vapor Mode is Vue's answer. It is an optional, per-component mode where the compiler turns a template directly into the DOM operations that build and update it, skipping the virtual DOM for that component. You opt in on the component itself, not for the whole app, so a Vapor component and an ordinary one can sit side by side and pass props and events between them.

<script setup vapor>
import { ref } from 'vue';

const count = ref(0);
</script>

<template>
  <button @click="count++">{{ count }}</button>
</template>

The trade is the one every compiler optimisation makes: less runtime work in exchange for more work at build time, and a smaller supported API surface. Vapor supports a subset of Vue โ€” Options API components do not qualify, and a few internals behave differently. It is still a release candidate as of this writing, so treat it as a preview rather than something to build on today. It does not replace the virtual DOM; it is a second rendering path you choose per component.

You are about to answer a short quiz on Vapor Mode.

  1. Vapor Mode compiles a template into direct DOM operations, skipping the virtual DOM for that component.
  2. You opt a single-file component into Vapor Mode with the `vapor` attribute on the ___ block.
  3. Turning on Vapor Mode for one component forces every other component in the app to use it too.
  4. Vapor Mode supports the full Vue API surface, including the Options API.
  5. Vapor Mode trades runtime work for more work at ___ time.
  6. As of this writing, Vapor Mode is still a release candidate rather than a stable release.