Skip to content
On this page

hoistStatic

Stability: stable

With enabling hoistStatic, constants declared in macros of <script setup> can be referenced.

For Vue >= 3.3, this feature will be turned off by default.

FeaturesSupported
Vue 3
Nuxt 3
Vue 2

Basic Usage

vue
<script setup lang="ts">
const name = 'AppFoo'
defineOptions({
  name,
})
</script>
Compiled Code
vue
<script lang="ts">
const name = 'AppFoo'
export default {
  name,
}
</script>

Magic Comments

vue
<script setup lang="ts">
// A value that's even not a constant
const name = /* hoist-static */ fn()
defineOptions({
  name,
})
</script>
Compiled Code
vue
<script lang="ts">
const name = fn()
export default {
  name,
}
</script>