Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

_christoph's avatar

Inertial, React, Laravel groups, and route names

So I'm trying to learn Laravel and Inertia at the same time so please forgive any apparent ignorance.

For my routes, I'm trying to set up a group with a prefix and a name. This is my code

 Route::prefix('narthex')->name('narthex')->group(function () {
    Route::get('/', [PagesController::class, 'index'])->name('entry');
    Route::get('/contact', [PagesController::class, 'contact'])->name('contact');
 });

And here is the code in my react component

href={route('narthex.contact')}
href={route('narthex.entry')}

The problem I'm experiencing is that when I load the page, I'm seeing the following exception:

Uncaught Error: Ziggy error: route 'narthex.entry' is not in the route list.

But according to the documentation on the routing page, the way I have it configured should be working.

When I run Ziggy.routes in the console, I see that the routes above are referenced as narthexentry and narthexcontact (without the . between). Why would those route names not be coming through using the Laravel paradigm where the names are separated with the dot?

What am I doing wrong? Any help would be greatly appreciated. Thanks!

Christoph

0 likes
5 replies
furqanDev's avatar
Level 18

There needs to be . at the end of narthex

 Route::prefix('narthex')->name('narthex.')->group(function () {
    Route::get('/', [PagesController::class, 'index'])->name('entry');
    Route::get('/contact', [PagesController::class, 'contact'])->name('contact');
 });
_christoph's avatar

@furqanDev Yeah, I suppose I can force it but I'm wondering why it isn't getting handled correctly. But in the route name prefixes section of the routes page, it even gives the example of // Route assigned name "admin.users".... In blade components, I know you can reference routes that way. Why isn't that the case here, too?

furqanDev's avatar

@_christoph It is handling it correctly saying the route isn't found because the route name is narthexentry if we don't put any . between them.

Prefix is appending in url, not setting the name. In the resource you don't have to worry about the.

You can just group them and do the following,

Route::group([ 'prefix' => '/narthex', 'as' => 'narthex.' ,'middleware' => ['your-middlewares']],function(){
	Route::get('/', [PagesController::class, 'index'])->name('entry');
    Route::get('/contact', [PagesController::class, 'contact'])->name('contact');
});
_christoph's avatar

@furqanDev Ok, I'm blind. In the same code on the routing page, I totally missed the dot in the example.

Route::name('admin.')->group(function () {

I iz be dumm sometimes. :/

Thank you very much for your replies! I marked your first one as the best answer since it's absolutely correct. Thanks again.

Please or to participate in this conversation.