Let a missing Vue page 404

A missing post already 404s through route model binding. Do not build a second Inertia error page for it.

For your AI agent

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

Read https://laravel-vuejs.space/laravel-abort-404-inertia-vue.md
A missing post already 404s through route model binding. Do not build a second Inertia error page for it.
Do not build a second Inertia error page for it.
Do not catch the exception and return Inertia::render('Errors/404') with a 200.
Do not redirect a missing post to the index and flash "not found".
Show the diff. Do not commit.
On this page · 3 sections
  1. The fix
  2. What to avoid
  3. FAQ

People searching “Inertia 404 page” render an empty Vue page when the id is wrong. Laravel already did this. A type-hinted model that does not exist throws ModelNotFoundException, and the app returns 404. The CRUD guide uses that type-hint.

TL;DR

  • A missing post already 404s through route model binding.
  • Do not build a second Inertia error page for it.
  • Do not catch the exception and return Inertia::render('Errors/404') with a 200.
  • Do not redirect a missing post to the index and flash “not found”.

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

Applies to: Laravel 13 · Inertia 3 · Vue 3

The fix#

php
public function show(Post $post): Response
{
    return Inertia::render('posts/Show', [
        'post' => $post->only(['id', 'title']),
    ]);
}

/posts/99999 never mounts Show. A v-if="post" on that page does not run. You do not need a custom error component for a missing row.

Post::findOrFail($id) is the same 404 when you are not using the route parameter.

What to avoid#

Gotcha

Do not catch the exception and return Inertia::render('Errors/404') with a 200. The status would be wrong, and the stack guide does not need a second error app. Do not redirect a missing post to the index and flash “not found”. The 404 is the honest response.

FAQ#

How do I let a missing Vue page 404?

A missing post already 404s through route model binding. Do not build a second Inertia error page for it.

What goes wrong with Inertia 404 page?

Many developers render an empty Vue page when the id is wrong. Do not catch the exception and return Inertia::render('Errors/404') with a 200.

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.