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

Antonio Orlando's avatar

usePage().props.value and computed()

This doesn't seem to work with vue 3 composition API, or am I doing something wrong?

const successMessage = computed(() => usePage().props.value.flash.success })

Did all imports but it doesn't return the message

0 likes
2 replies
Niush's avatar
Niush
Best Answer
Level 50

There is a little } (curly bracket) in your code. Is that a bug? This should work:

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

const successMessage = computed(() => usePage().props.value.flash.success);
</script>

Also, Make sure backend is returning the flash message correctly with Vue DevTools.

Antonio Orlando's avatar

Thanks @niush! I should have checked the code better. It also needs to add ".value" to the const that is using the computed property, otherwise it won't work

Please or to participate in this conversation.