How do I add middleware->auth on Livewire routes such as Route::livewire('/home', 'counter')

How do I add middleware->auth on Livewire routes such as
Route::group([‘layout’ => ‘layouts.base’, ‘section’ => ‘body’], function () {
Route::livewire(’/home’, ‘counter’)
});

Tried to add it the way I add to get routes the page is loading infinitely.

Hey @Auzaay,

you could simply add the Middleware to your surrounding group:

Route::group([‘layout’ => ‘layouts.base’, ‘section’ => ‘body’, 'middleware' => ['auth']], function () {
    Route::livewire(’/home’, ‘counter’)
});
1 Like

thanks @maxeckel! works like a charm.