# 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.

- URL: https://laravel-vuejs.space/laravel-vue-flash
- Author: Anass Ez-zouaine (https://laravel-vuejs.space/author/anass-ez-zouaine)
- Published: 2026-10-10
- Topics: Laravel, VueJs, Inertia

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](https://laravel-vuejs.space/laravel-inertia-vue-crud) 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](https://laravel-vuejs.space/laravel-vue-notifications). The stack is [Laravel and Vue in 2026](https://laravel-vuejs.space/laravel-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:**

`app/Http/Controllers/PostController.php`
```php
return to_route('posts.index')->with('success', 'Saved.');
```

**Shows the toast:**

`app/Http/Controllers/PostController.php`
```php
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.php`
```php
Inertia::flash('success', 'Saved.');

return to_route('posts.index');
```

`resources/js/layouts/AppLayout.vue`
```vue
<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.php`
```php
$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

**Q: 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.

**Q: 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.

**Q: Which toast types does the starter kit support?**

`success`, `info`, `warning` and `error`.

## Next steps

- [Build a CRUD with Laravel, Inertia and Vue](https://laravel-vuejs.space/laravel-inertia-vue-crud): the save this toast confirms.
- [Database notifications in Vue](https://laravel-vuejs.space/laravel-vue-notifications): messages that persist.
- [Keep the layout between Inertia visits](https://laravel-vuejs.space/inertia-vue-persistent-layout): where the flash line lives.
- [Inertia docs: flash data](https://inertiajs.com/docs/v3/data-props/flash-data)

## Sources

- [Inertia v3: Flash data](https://inertiajs.com/docs/v3/data-props/flash-data)
- [Laravel Vue starter kit](https://github.com/laravel/vue-starter-kit)
