route() in React or Vue throws that a Laravel route is not in Ziggy's list
Your error
Uncaught Error: Ziggy error: route 'posts.index' is not in the route list.1 more line it can showFix it fast
Most common cause, 1 of 4The Laravel route has no name, or a different one
Give the route a unique name in routes/web.php, and call route() with the full name including any group prefix.
// routes/web.php
Route::get('/posts', [PostController::class, 'index'])->name('posts.index');
// React or Vue component
route('posts.index');Short answer
Ziggy error: route 'x' is not in the route list means the routes Ziggy sent to the browser lack that name. Ziggy only exports named routes, so first add ->name() in Laravel. If php artisan route:list shows the name, regenerate ziggy.js, check the only, except and groups filters, and rebuild the route cache. Applies to Ziggy 2.7 on Laravel 13.
Which cause do you have?
Ask Laravel for the route's name, then check what Ziggy sent. A name missing from route:list is cause 1. A name Laravel lists but Ziggy lacks points to causes 2 to 4: with @routes, test it with route().has() in the browser console; with an imported ziggy.js, search that file.
php artisan route:list --except-vendor
# pages using @routes, in the browser devtools console:
route().has('posts.index')
# apps importing a generated file:
grep -c "posts.index" resources/js/ziggy.jsThen find the line you see in this list and open its fix:
- 1The Laravel route has no name, or a different one
The route's row in route:list has an empty name, or the name carries a group prefix such as admin. - 2The front end imports a ziggy.js generated before the route existed
The app imports Ziggy from a ziggy.js file instead of using the @routes Blade directive - 3config/ziggy.php or a @routes group filters the route out
config/ziggy.php has an only, except or groups key, or the layout calls @routes('somegroup') - 4The server still runs on a route cache built before the deploy
The page works locally but fails on the server, where the deploy runs php artisan route:cache or php artisan optimize
What does the error look like?
Uncaught Error: Ziggy error: route 'posts.index' is not in the route list.Ziggy error: route 'dashboard' is not in the route list.
Cause 1 of 4
The Laravel route has no name, or a different one
You seeThe route's row in route:list has an empty name, or the name carries a group prefix such as admin.
Check
Ziggy's route list is built from Laravel's named routes only, so a route without ->name() can never be found and route() throws the not-in-the-route-list error. A name prefix from Route::name('admin.') is part of the name, so 'users.index' and 'admin.users.index' are different keys.
php artisan route:list --except-vendor | grep postsFix
Give the route a unique name in routes/web.php, and call route() with the full name including any group prefix.
// routes/web.php
Route::get('/posts', [PostController::class, 'index'])->name('posts.index');
// React or Vue component
route('posts.index');Verify
route:list shows posts.index, and route('posts.index') in the console returns the URL.
route('posts.index')Confirmed by raw.githubusercontent.com
Cause 2 of 4
The front end imports a ziggy.js generated before the route existed
You seeThe app imports Ziggy from a ziggy.js file instead of using the @routes Blade directive
Check
php artisan ziggy:generate writes the config and routes to resources/js/ziggy.js (or ziggy.output.path). Without @routes, that file is all route() knows, so a route added after the last generate run is missing from it.
grep -c "posts.index" resources/js/ziggy.jsFix
Run the generate command again after every route change and rebuild the assets. Adding it to the script that runs your build stops the file going stale.
php artisan ziggy:generate
npm run buildVerify
The grep now finds the route name in ziggy.js and the page renders without the error.
grep -c "posts.index" resources/js/ziggy.jsConfirmed by raw.githubusercontent.com
Cause 3 of 4
config/ziggy.php or a @routes group filters the route out
You seeconfig/ziggy.php has an only, except or groups key, or the layout calls @routes('somegroup')
Check
Ziggy applies the only or except patterns from config/ziggy.php to the names it sends, and @routes('author') sends just the routes in that group. A name that no pattern lets through is hidden from route() even though Laravel serves it. Setting both only and except switches filtering off.
cat config/ziggy.php
grep -rn "@routes" resources/viewsFix
Add a pattern that matches the name to only (or to the group the page uses), or take it out of except. If the server caches its config, clear that cache so the edited file is used.
// config/ziggy.php
return [
'only' => ['home', 'posts.*'],
];
// then: php artisan config:clearVerify
route().has('posts.index') returns true on the page that failed.
route().has('posts.index')Confirmed by raw.githubusercontent.com
Cause 4 of 4
The server still runs on a route cache built before the deploy
You seeThe page works locally but fails on the server, where the deploy runs php artisan route:cache or php artisan optimize
Check
Once php artisan route:cache has run (php artisan optimize runs it too), Laravel loads the cached file on every request, and routes added since then stay invisible until the cache is rebuilt. The list that @routes prints comes from that router, so the browser misses the new name as well.
grep -rnE "route:cache|artisan optimize" --include=*.sh --include=*.yml .Fix
Clear the stale cache, then rebuild it as a step that runs after the new code is on the server, never before.
php artisan route:clear
php artisan route:cacheVerify
Reload the page on the server; route().has() returns true and the error is gone.
php artisan route:list --except-vendor | grep posts.indexConfirmed by laravel.com
How do I stop it coming back?
- Name every route the front end calls, and treat a missing ->name() as a review comment.
- Run php artisan ziggy:generate inside the same npm script that builds the assets, if you import ziggy.js.
- In the deploy script, place route:cache after the code checkout and composer install.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: Spotless Laundry, EZ Estimater, TaxiDex.