Table of contents

Error: Ziggy error: route is not in the route list

How to fix "Error: Ziggy error: route is not in the route list" error. Common error in Laravel with Inertia.js and Vue.js. Easy simple fix! You will kick yourself.

How to fix “Error: Ziggy error: route ‘your-route’ is not in the route list” error

If you are encountering the error “Error: Ziggy error: route ‘your-route’ is not in the route list” the solutions is most likely very simple. This is an error I came across when using Laravel with Inertia.js and Vue.js. There are a couple of things you need to check to get this sorted.

How to resolve Error: Ziggy error: route ‘your-route’ is not in the route list error

If you are trying to resolve the Error: Ziggy error: route ‘your-route’ is not in the route list error, this is what you need to do:

  1. Check the route name actually exists

    I’m sure you have checked this already. But check that the route does actually exist. Make sure the name is EXACTLY the same. Check for a typo. I know it sounds obvious. But often it is something obvious!

  2. Check the route path

    The issue for me was that I had copied a route and pasted it. I had then changed the name of my copied route. However the original route and the newly created route both had the same url and request method. This meant that whilst it looked like the route did exist. It was getting overwritten by my newly created route. Simple solution is to change the url in the new route!

Example of how this error occurs

So you have a nice working route looking like this:

...
Route::middleware(['auth:sanctum', 'verified'])->get('adverts', [AdvertController::class, 'index'])
    ->name('advert');
...

Then you copy the route and paste it to create a new similar route. You rename the route and your routes/web.php file looks like this:

...
Route::middleware(['auth:sanctum', 'verified'])->get('adverts', [AdvertController::class, 'index'])
    ->name('adverts');
Route::middleware(['auth:sanctum', 'verified'])->get('adverts', [AdvertController::class, 'index'])
    ->name('adverts.my_adverts');
...

Everything seems fine. You have 2 routes with different names. But now you are encountering the Error: Ziggy error: route ‘your-route’ is not in the route list error.

The reason for this is that both routes are for GET requests, and they both have the same path! Simply changing the path of the second route will sort the problem out:

...
Route::middleware(['auth:sanctum', 'verified'])->get('adverts', [AdvertController::class, 'index'])
    ->name('adverts');
Route::middleware(['auth:sanctum', 'verified'])->get('my-adverts', [AdvertController::class, 'index'])
    ->name('adverts.my_adverts');
...
John

I have videos too!

If you found this post helpful, please consider subscribing to the @codingoblin YouTube channel 😀

You might be interested in these

Want updates when I release something interesting?

Sign up for my newsletter to stay up to date.