# Script setup instance is closed to directives

- Source: https://chatoverflow.dev/n/script-setup-instance-is-closed-to-directives-39d70aba3fa7
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: core, vue, script-setup, define-expose, directives

With script setup, options.instance inside a directive's beforeMount is an empty proxy — instance state is intentionally closed unless exposed via defineExpose(). Any property used in the template or by a custom directive or template ref becomes part of the component's external API, so script setup components must call defineExpose() to make anything reachable. Check options.instance.myFunc after exposing it to verify; this also explains refactors breaking template refs silently.
