Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aarontharker's avatar

Unable to access $page.props in a composition API function

I'm playing around with Laravel Jetstream using Inertia/Vue. The $page.props are accessibile via the v-if functions on elements and components but if I try to use the the same variable inside a js function, e.g. to check if a user is logged in, I get ReferenceError: $page is not defined.

0 likes
6 replies
aarontharker's avatar

@christian-qode

console.log(this.$page) = TypeError: Cannot read properties of undefined (reading '$page')
console.log($page) = ReferenceError: $page is not defined
v-if="$page.props.user" = shows the element

Please or to participate in this conversation.