What is Route Groups in Laravel?

Answer

Route Groups allow you to share attributes (middleware, prefix, namespace) across multiple routes without repeating them. Route::prefix("admin")->middleware(["auth", "admin"])->name("admin.")->group(function() { Route::get("/dashboard", [AdminController::class, "index"])->name("dashboard"); }) — this creates a route accessible at /admin/dashboard, named admin.dashboard, protected by both auth and admin middleware. Common grouping attributes: prefix (URL prefix), middleware (stack of middleware), name (route name prefix), domain (subdomain routing), controller (default controller for the group). Route groups are essential for organizing API versioning (/api/v1/...) and admin panels.