PHPackages                             tanthammar/livewire-auto-routes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. tanthammar/livewire-auto-routes

ActivePackage[API Development](/categories/api)

tanthammar/livewire-auto-routes
===============================

Auto generate routes for Laravel Livewire Components.

1.1.1(4y ago)19821MITPHPPHP ^8.0

Since May 17Pushed 4y agoCompare

[ Source](https://github.com/TinaHammar/livewire-auto-routes)[ Packagist](https://packagist.org/packages/tanthammar/livewire-auto-routes)[ RSS](/packages/tanthammar-livewire-auto-routes/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

livewire-auto-routes
====================

[](#livewire-auto-routes)

Auto generate routes for Laravel Livewire Components.

[![Latest Stable Version](https://camo.githubusercontent.com/0850d6818d64a6538aadc282bef9799f8affeeebe48c83843f3e7cc4a597f953/68747470733a2f2f706f7365722e707567782e6f72672f74616e7468616d6d61722f6c697665776972652d6175746f2d726f757465732f76)](//packagist.org/packages/tanthammar/livewire-auto-routes)[![Latest Unstable Version](https://camo.githubusercontent.com/426a30424f5972dfee020293e3ee2cf5e674207aca3d75d71c6b7d8f3afa7b84/68747470733a2f2f706f7365722e707567782e6f72672f74616e7468616d6d61722f6c697665776972652d6175746f2d726f757465732f762f756e737461626c65)](//packagist.org/packages/tanthammar/livewire-auto-routes)[![Total Downloads](https://camo.githubusercontent.com/fce5ecfb2f5c23633218a0f683e71ffb9eb417fc3977ccb0870e807f407c70b5/68747470733a2f2f706f7365722e707567782e6f72672f74616e7468616d6d61722f6c697665776972652d6175746f2d726f757465732f646f776e6c6f616473)](//packagist.org/packages/tanthammar/livewire-auto-routes)[![GitHub issues](https://camo.githubusercontent.com/4d71f3d72ad8b4866c9b50f9bb9832f7a50b5c7a8ff322ce194432e0a5c491f3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f54696e6148616d6d61722f6c697665776972652d6175746f2d726f75746573)](https://github.com/TinaHammar/livewire-auto-routes/issues)[![GitHub stars](https://camo.githubusercontent.com/7425cd29983ffc5c8018b7cb192f8553c4d74d2d724d413ff2df1638a79f348e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f54696e6148616d6d61722f6c697665776972652d6175746f2d726f75746573)](https://github.com/TinaHammar/livewire-auto-routes/stargazers)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

Requirements
============

[](#requirements)

- Livewire 2
- Laravel 8
- php 8

Use Spatie pkg
==============

[](#use-spatie-pkg)

I recommend that you try [Spatie Laravel Route Attributes](https://github.com/spatie/laravel-route-attributes) before installing this package.

Installation
============

[](#installation)

```
composer require tanthammar/livewire-auto-routes

```

Routes in `web.php` takes precedence!
=====================================

[](#routes-in-webphp-takes-precedence)

You can use web.php as normal. Routes declared in your Livewire components are registered after the routes in web.php.

Usage
=====

[](#usage)

- You generate routes via traits or by adding a `route()` method to your Livewire component.
- Your Livewire components can exist in any folder inside the `app` namespace.
- If you don't add any of the traits or the `route()` method, the Livewire component is treated just as a normal component, thus ignored by this package.

### Guest route Trait

[](#guest-route-trait)

- Applies the `guest` middleware.
- **The property is used to generate both the route name and url.**

```
use Tanthammar\LivewireAutoRoutes\HasGuestRoute;

class FooComponent extends \Livewire\Component
{
    use HasGuestRoute;

    protected string $guestRoute = '/foo/{id}/edit'; //route name becomes 'foo.id.edit'
}
```

### Auth route Trait

[](#auth-route-trait)

- Applies the `auth` middleware.
- **The property is used to generate both the route name and url.**

```
use Tanthammar\LivewireAutoRoutes\HasAuthRoute;

class FooComponent extends \Livewire\Component
{
    use HasAuthRoute;

    protected string $authRoute = '/foo/{name?}'; //route name becomes 'foo.name'
}
```

Custom routes
=============

[](#custom-routes)

### Option 1

[](#option-1)

Declare the route just like you would in `web.php`

```
use Illuminate\Support\Facades\Route;

class FooComponent extends \Livewire\Component
{
    public function route(): \Illuminate\Routing\Route|array
    {
        return Route::get('foo', static::class)
            ->middleware('auth') //default middleware is 'web'
            ->name('foo');
    }
}
```

### Option 2, use the RouteMaker

[](#option-2-use-the-routemaker)

The RouteMaker can auto-generate the route name from the route definition, but it's optional.

```
use Tanthammar\LivewireAutoRoutes\RouteMaker;

class FooComponent extends \Livewire\Component
{
    public function route(): RouteMaker
    {
        return new RouteMaker(
            route: 'users/{id}/edit', //if you omit $name, this route name will become 'users.id.edit'
            middleware: ['auth:sanctum', 'verified'],
            component: static::class,
            name: 'users.edit' //OPTIONAL, else $name will be generated from $route
        );
    }
}
```

Routes are registered in alphabetical order!
============================================

[](#routes-are-registered-in-alphabetical-order)

Livewire component **FILES** are looped in alphabetical order in the `app namespace`. One way to control the load order is to group your components in subfolders with suitable names like `routeGroupA`, `routeGroupB`, where routes in *"routeGroup**A**"* would be registered before *"routeGroup**B**"*.

Example using the Traits
========================

[](#example-using-the-traits)

It's recommended to keep a controlled naming structure to avoid route conflicts. Use the `RouteMaker` if you want better naming.

Directory(asc) = load order$authRoute or $guestRouteGenerated route nameApp/Foo/Users/Create.phpusers/createusers.createApp/Foo/Users/CustomStuff.phpusers/custom-stuff/{id}users.custom-stuff.idApp/Foo/Users/Delete.phpusers/delete/{id}users.delete.idApp/Foo/Users/Edit.phpusers/edit/{id}users.edit.idApp/Foo/Users/Index.phpusersusersApp/Foo/Users/Show.phpusers/{id}users.id### 💬 Let's connect

[](#-lets-connect)

Discuss with other tall-form users on the official Livewire Discord channel. You'll find me in the "partners/tall-forms" channel.

- [🔗 **Discord**](https://discord.gg/livewire)
- [🔗 **Twitter**](https://twitter.com/TinaHammar)
- [🔗 **Youtube**](https://www.youtube.com/channel/UCRPTsZ2OduwzGq3EdiynY2Q)
- [🔗 **Devdojo**](https://devdojo.com/tinahammar)

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

### Contributing

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security-related issues, please open an issue.

### License

[](#license)

The MIT License (MIT). Please see [License File](/LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

1820d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e71fd6e89c09af4ce7dc4a1c4fd3e04716326b6e98ed9003f092a8462a5ef422?d=identicon)[Stockholm](/maintainers/Stockholm)

---

Top Contributors

[![tanthammar](https://avatars.githubusercontent.com/u/21239634?v=4)](https://github.com/tanthammar "tanthammar (22 commits)")

---

Tags

laravellivewireauto-routes

### Embed Badge

![Health badge](/badges/tanthammar-livewire-auto-routes/health.svg)

```
[![Health](https://phpackages.com/badges/tanthammar-livewire-auto-routes/health.svg)](https://phpackages.com/packages/tanthammar-livewire-auto-routes)
```

###  Alternatives

[livewire/flux

The official UI component library for Livewire.

9385.0M86](/packages/livewire-flux)[mollie/laravel-mollie

Mollie API client wrapper for Laravel &amp; Mollie Connect provider for Laravel Socialite

3624.1M28](/packages/mollie-laravel-mollie)[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)[mati365/ckeditor5-livewire

CKEditor 5 integration for Laravel Livewire

413.9k](/packages/mati365-ckeditor5-livewire)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

116.6k](/packages/tomshaw-electricgrid)[mwguerra/web-terminal

A web-based terminal component for Filament/Laravel with command whitelisting and multiple connection types

251.1k](/packages/mwguerra-web-terminal)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
