Show a saved message in Vue

Inertia 3 can flash a toast for one visit. The Vue starter kit already displays it. A Laravel with() call does not reach that toast.

For your AI agent

Copies a prompt. Paste it into the AI agent you already have open.

Read https://laravel-vuejs.space/laravel-vue-flash.md
Inertia 3 can flash a toast for one visit. The Vue starter kit already displays it. A Laravel with() call does not reach that toast.
Do not install another toast package.
Do not register a second router.on('flash').
Show the diff. Do not commit.

Next: Laravel and Vue CRUD with Inertia

On this page · 7 sections
  1. On the Vue starter kit
  2. A line in the layout
  3. A test
  4. Recap
  5. FAQ
  6. Next steps
  7. Sources

You save a post, Laravel redirects to the list, and the list looks exactly like before. Did it work? Give the reader a one-time “Saved.” toast with Inertia 3’s flash data, and skip the session key the starter kit never reads.

TL;DR

  • Call Inertia::flash('toast', ['type' => 'success', 'message' => 'Saved.']) before the redirect.
  • The kit’s initializeFlashToast() already displays it. Don’t add another toast package.
  • ->with('success', ...) writes Laravel’s session, which the kit’s toast doesn’t read.
  • Test it with assertInertiaFlash('toast.message', 'Saved.').

What you'll learn

  • How to flash a toast the starter kit already shows
  • Why ->with() stays silent
  • How to show a flash line without the kit, and how to test it

Who it's for: Laravel + Vue developers on the Inertia 3 starter kit

Applies to: Laravel 13 · Vue starter kit · inertia-laravel 3 · @inertiajs/vue3 3.9 · Pest

The CRUD guide saves a post and redirects to the list. The list looks the same as it did before the save. The reader has no signal that the write worked.

Inertia 3 has a flash for that. It lives for the next response, then it is gone. The back button does not bring it back, because it is not stored in the history entry. A row in the notifications table is a different feature, the database bell. The stack is Laravel and Vue in 2026.

On the Vue starter kit#

The kit already listens. resources/js/app.ts calls initializeFlashToast(), and that function reads flash.toast and hands it to the toast that ships with the kit. Do not install another toast package. Do not register a second router.on('flash').

Flash this shape before the redirect the CRUD store method already returns:

Silent, then Shows the toast:

app/Http/Controllers/PostController.phpphp
return to_route('posts.index')->with('success', 'Saved.');
app/Http/Controllers/PostController.phpphp
use Inertia\Inertia;

Inertia::flash('toast', [
    'type' => 'success',
    'message' => 'Saved.',
]);

return to_route('posts.index');

type is success, info, warning, or error. The kit’s profile controller uses the same array when it updates the account. Match it. A plain string under another key will not reach that listener.

Gotcha: with() is a different flash

A with() call on that redirect writes Laravel’s session. The kit is not reading that key. The toast stays quiet.

A line in the layout#

Use this when the app does not call initializeFlashToast(). Flash a string and print it once. On the starter kit, prefer the toast array above so you do not show the same sentence twice.

app/Http/Controllers/PostController.phpphp
Inertia::flash('success', 'Saved.');

return to_route('posts.index');
resources/js/layouts/AppLayout.vuevue
<script setup lang="ts">
import { usePage } from "@inertiajs/vue3";

const page = usePage();
</script>

<template>
  <p v-if="page.flash.success">{{ page.flash.success }}</p>
  <slot />
</template>

Tip: put it in the layout

Put that p in the layout that wraps the pages, not in one form. The next visit clears it. You do not delete it yourself.

A test#

assertInertiaFlash reads the flash on the redirect. It does not need the Vue page to render.

tests/Feature/PostTest.phpphp
$this->post('/posts', [
    'title' => 'Hello Laravel 13',
    'excerpt' => 'A short excerpt.',
])->assertRedirect('/posts')
    ->assertInertiaFlash('toast.message', 'Saved.');

A banner that flashes success asserts that key with the same method. The rest of the create test stays in the CRUD guide.

Run it

bash
php artisan test --filter=PostTest

Recap#

  • Inertia flash data lives for one response and never comes back with the back button.
  • On the starter kit, flash a toast array with type and message.
  • ->with() writes Laravel’s session flash, a different channel.
  • Assert it with assertInertiaFlash.

FAQ#

Why does my Laravel with() message not show in Vue?

The starter kit’s toast reads Inertia flash data (flash.toast), not the Laravel session key that with() writes. Use Inertia::flash() instead.

Does the flash message come back when I press the back button?

No. Inertia flash data is not stored in the history entry, so it only shows on the response that set it.

Which toast types does the starter kit support?

success, info, warning and error.

Next steps#

Sources#

Found this useful?

Ask questions, share what you built.

Join thousands of Laravel and Vue developers in our Facebook group, or get new posts in your Telegram feed. Sharing this article helps too.

Keep reading

Newsletter

Get the best of Laravel & Vue, once a month.

One short email with new guides, release notes worth reading and hand-picked community links. No spam, unsubscribe any time.