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

devmenezes's avatar

Watch props Vue 3 + Inertia + composition API

How can I watch for flash messages?

watch $page.props.value.flash

1 like
3 replies
Niush's avatar
Niush
Best Answer
Level 50
<script setup>
import { usePage } from '@inertiajs/inertia-vue3';
import { computed, ref, watch } from 'vue';

const page = usePage();

const showFlash = ref(false);

const flash = computed(function () {
  return page.props.value.flash;
});

watch(page.props, function (val) {
  if (val?.flash) {
    showFlash.value = true;
  }
}, {
  immediate: true,
  deep: true,
});
</script>

<template>
	<div v-if="showFlash && flash.message" @click="showFlash = false">
        {{ flash.message }} - {{ flash.type }}
    </div>
</template>
9 likes

Please or to participate in this conversation.