Skip to content

In Vue 3, how to get $page.props value in setup() ? #505

Answered by reinink
sarukomine asked this question in Help (Vue)
Discussion options

You must be logged in to vote

Yeah, we need to add the usePage() hook to the docs still. Here's how to do this:

<template>
  <div>Logged in as: {{ user.name }}</div>
</template>

<script>
import { computed } from 'vue'
import { usePage } from '@inertiajs/inertia-vue3'

export default {
  setup() {
    const user = computed(() => usePage().props.value.user)
    return { user }
  },
}
</script>

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@RobertBoes
Comment options

@sarukomine
Comment options

@reinink
Comment options

Answer selected by claudiodekker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants