Flash an error toast in Vue

The kit's toast reads flash.toast. An error uses the same array with type error. with() does not reach it.

For your AI agent

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

Read https://laravel-vuejs.space/inertia-flash-error-vue.md
The kit's toast reads flash.toast. An error uses the same array with type error. with() does not reach it.
Do not flash the exception message.
Show the diff. Do not commit.
On this page · 3 sections
  1. The fix
  2. What to avoid
  3. FAQ

People searching “Inertia flash error” put the sentence in with('error') and the toast stays quiet. The flash guide shows the success shape the Vue starter kit already listens for. An error is the same array.

TL;DR

  • The kit’s toast reads flash.toast.
  • An error uses the same array with type error.
  • with() does not reach it.
  • Do not flash the exception message.

Who it's for: Laravel + Vue developers on Inertia

Applies to: Laravel 13 · Inertia 3 · Vue 3

The fix#

php
use Inertia\Inertia;

Inertia::flash('toast', [
    'type' => 'error',
    'message' => 'Could not publish that post.',
]);

return back();

type is success, info, warning, or error. The kit’s initializeFlashToast() reads flash.toast. A string on another key never arrives.

Use this for a failure that is not a validation error. A bad title still belongs in form.errors.title from validate(). A toast and a field error for the same mistake makes the user read it twice.

What to avoid#

Gotcha

Do not flash the exception message. It can include SQL or a path. Write a sentence you would say to the person using the page.

FAQ#

How do I flash an error toast in Vue?

The kit's toast reads flash.toast. An error uses the same array with type error. with() does not reach it.

What goes wrong with Inertia flash error?

Many developers put the sentence in with('error') and the toast stays quiet. Do not flash the exception message.

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.