PHPackages                             macellan/laravel-js-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. macellan/laravel-js-routes

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

macellan/laravel-js-routes
==========================

Laravel routes from Javascript

2.3(1y ago)325.9k↓63.7%2MITPHPPHP &gt;=7.2.0

Since Feb 6Pushed 1y agoCompare

[ Source](https://github.com/macellan/laravel-js-routes)[ Packagist](https://packagist.org/packages/macellan/laravel-js-routes)[ RSS](/packages/macellan-laravel-js-routes/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (7)Versions (11)Used By (0)

Laravel Javascript Routes
=========================

[](#laravel-javascript-routes)

Why
---

[](#why)

I love the Laravel routing system and I often use named routes like `route('users.show', array('id' => 1))` to generate `http://domain.tld/users/1`. With the amazing uprising of Javascript frameworks (AngularJS, EmberJS, Backbone, etc.) it's hard to track changes on your routes between the backend and the REST calls from your Javascript. The goal of this library is to expose those named routes to your frontend so you can do: `Router.route('users.show', {id: 1})` and get the same result.

Installation
------------

[](#installation)

You can install this package via composer:

```
composer require macellan/laravel-js-routes
```

Usage
-----

[](#usage)

By default the command will generate a `routes.js` file on your project root. This contains all **named** routes in your app. That's it! You're all set to go. Run the `artisan` command from the Terminal to see the new `routes:javascript` commands.

```
php artisan routes:javascript
```

> **Lazy Tip** If you use Grunt, you could set up a watcher that runs this command whenever your routes files change.

Arguments
---------

[](#arguments)

NameDefaultDescription**name***routes.js*Output filenameOptions
-------

[](#options)

NameDefaultDescription**path***base\_path()*Where to save the generated filename. (ie. public assets folder)**object***Router*If you want to choose your own global JS object (to avoid collision)**prefix***null*If you want to a path to prefix to all your routesJavascript usage
----------------

[](#javascript-usage)

You have to include the generated file in your views (or your assets build process).

```

```

And then you have a `Routes` object on your global scope. You can use it as:

```
Router.route(route_name, params)
```

Example:

```
Router.route('users.show', {id: 1}) // returns http://dommain.tld/users/1
```

If you assign parameters that are not present on the URI, they will get appended as a query string:

```
Router.route('users.show', {id: 1, name: 'John', order: 'asc'}) // returns http://dommain.tld/users/1?name=John&order=asc
```

Contributing
------------

[](#contributing)

```
composer install --dev
./vendor/bin/phpunit
```

```
npm install -g grunt-cli
npm install
grunt travis --verbose
```

In addition to a full test suite, there is Travis integration.

Found a bug?
------------

[](#found-a-bug)

Please, let me know! Send a pull request or a patch. Questions? Ask! I will respond to all filed issues.

Inspiration
-----------

[](#inspiration)

Although no code was copied, this package is greatly inspired by [FOSJsRoutingBundle](https://github.com/FriendsOfSymfony/FOSJsRoutingBundle) for Symfony.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance44

Moderate activity, may be stable

Popularity32

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 82.6% 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 ~454 days

Recently: every ~468 days

Total

10

Last Release

443d ago

Major Versions

1.6 → 2.02020-03-02

PHP version history (3 changes)1.0PHP &gt;=5.3.0

1.6PHP &gt;=5.4.0

2.0PHP &gt;=7.2.0

### Community

Maintainers

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

![](https://avatars.githubusercontent.com/u/1533697?v=4)[Burak Çalık](/maintainers/burakcalik)[@BurakCalik](https://github.com/BurakCalik)

---

Top Contributors

[![fedeisas](https://avatars.githubusercontent.com/u/251675?v=4)](https://github.com/fedeisas "fedeisas (57 commits)")[![faytekin](https://avatars.githubusercontent.com/u/4013224?v=4)](https://github.com/faytekin "faytekin (7 commits)")[![zaalbarxx](https://avatars.githubusercontent.com/u/3301242?v=4)](https://github.com/zaalbarxx "zaalbarxx (3 commits)")[![bcalik](https://avatars.githubusercontent.com/u/9222368?v=4)](https://github.com/bcalik "bcalik (1 commits)")[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")

---

Tags

laravelartisanroutinggenerators

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/macellan-laravel-js-routes/health.svg)

```
[![Health](https://phpackages.com/badges/macellan-laravel-js-routes/health.svg)](https://phpackages.com/packages/macellan-laravel-js-routes)
```

###  Alternatives

[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M201](/packages/laravel-ai)[laravel/folio

Page based routing for Laravel.

603583.7k33](/packages/laravel-folio)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[laravel/surveyor

Static analysis tool for Laravel applications.

86121.4k13](/packages/laravel-surveyor)

PHPackages © 2026

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