This can be caused if you stay on the same template/render. You can also try to call the flash message via Session Facade.
use Illuminate\Support\Facades\Session;
Session::flash('message', 'User Has Been Updated');
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I want to display flash message everytime when request sent. But it show only once when same flash message and page redirect
Layout:
<div v-if="$page.props.flash.message">
<Notification :message="$page.props.flash.message" />
</div>
Controller:
return back()->with('message', 'User Has Been Updated');
Notification Components:
<script setup>
import { ref, onMounted } from 'vue'
defineProps({
message: String
});
const showNotification = ref(false);
onMounted(() => {
showNotification.value = true;
setTimeout(() => showNotification.value = false, 2000);
});
</script>
<template>
<div v-if="message && showNotification" class="flex items-center relative w-full p-4 mb-4 text-base leading-5 text-white bg-green-500 rounded-lg opacity-100 font-regular" role="alert">
<svg class="flex-shrink-0 inline w-4 h-4 me-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
</svg>
<span class="sr-only">Info</span>
<div>
<span class="font-medium capitalize">{{ message }}</span>
</div>
</div>
</template>
HandleInertiaRequests:
'flash' => [
'message' => fn () => $request->session()->get('message')
],
@acemgln0191 Update your code in script setup like this, to reset the shared flash message prop. I've tested it and this should work.
<script setup>
/* Add usePage, your import might be different than mine so double check this */
import { usePage } from "@inertiajs/vue3";
import { ref, onMounted } from 'vue'
defineProps({
message: String
});
const showNotification = ref(false);
const hideFlash = () => {
showNotification.value = false;
usePage().props.flash.message = "";
};
onMounted(() => {
showNotification.value = true;
setTimeout(() => hideFlash(), 2000);
});
</script>
Please or to participate in this conversation.