PHPackages                             bmatovu/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. bmatovu/laravel-js-routes

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

bmatovu/laravel-js-routes
=========================

Laravel Javascript routes.

v2.2.1(3y ago)871[1 issues](https://github.com/mtvbrianking/laravel-js-routes/issues)MITPHPPHP ^7.0|^8.0

Since Jun 3Pushed 3y agoCompare

[ Source](https://github.com/mtvbrianking/laravel-js-routes)[ Packagist](https://packagist.org/packages/bmatovu/laravel-js-routes)[ Docs](https://github.com/mtvbrianking/laravel-js-routes)[ RSS](/packages/bmatovu-laravel-js-routes/feed)WikiDiscussions master Synced yesterday

READMEChangelog (7)Dependencies (8)Versions (9)Used By (0)

Laravel JS Routes.
------------------

[](#laravel-js-routes)

[![Build Status](https://camo.githubusercontent.com/66e992bd52044ad4809835f06363dcc38e28fae2517e1fcdb8a099baa9e3ad1b/68747470733a2f2f7472617669732d63692e6f72672f6d7476627269616e6b696e672f6c61726176656c2d6a732d726f757465732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mtvbrianking/laravel-js-routes)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/cb3f0fbd708f4bdcda6acb72dafd58e0e0e39aa8bc6f3e0cdaa578b52808cecc/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d7476627269616e6b696e672f6c61726176656c2d6a732d726f757465732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mtvbrianking/laravel-js-routes/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/b37887f5006ff5280f0921fa3691c9119fd990c86c002fb0d6cb0ab8d17a527c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d7476627269616e6b696e672f6c61726176656c2d6a732d726f757465732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mtvbrianking/laravel-js-routes/?branch=master)[![StyleCI](https://camo.githubusercontent.com/5b0cf63ea4285f606bdff9e9961222c14928132181e5c1d573ded24906e6448a/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3236393030333532382f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/269003528)[![Documentation](https://camo.githubusercontent.com/70c5babcdd071a16af5cf30083ca75172d1117c028397189392c688efcf6f25a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f63756d656e746174696f6e2d426c7565)](https://mtvbrianking.github.io/laravel-js-routes)

This minimalistic package will help you access exisiting PHP routes via JavaScript.

### [Installation](https://packagist.org/packages/bmatovu/laravel-js-routes)

[](#installation)

Install via Composer package manager:

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

### Setup

[](#setup)

Set application URL in the environment file; `.env`.

```
APP_URL="http://localhost:8000"
```

Add application URL to base layout head meta; usually in `resources/views/layouts/app.blade.php`

```

```

### Generate routes

[](#generate-routes)

```
php artisan js-routes:generate
```

Routes will be written to a json file: `resources/js/routes.json`

*You should `.gitignore` the above auto-generated file.*

### Publish resources

[](#publish-resources)

Publish JavaScript router to `resources/js`

```
php artisan vendor:publish --provider="Bmatovu\JsRoutes\JsRoutesServiceProvider"
```

**Using Webpack | Laravel Mix**

Load JavaScript router; usually in `resources/js/app.js`

```
window.route = require('./router.js').route;

console.log(route('login'));
```

**Using ViteJS**

```
import { route } from './router.mjs';
window.route = route;

console.log(route('login'));
```

### Compile JS routes

[](#compile-js-routes)

```
npm run dev
```

### Usage

[](#usage)

Sample Laravel (named) routes

```
$int = '^\d+$';

Route::pattern('post', $int);
Route::pattern('comment', $int);

Route::group(['prefix' => 'posts', 'as' => 'posts.'], function () {
    Route::get('/', 'PostController@index')->name('index');
    Route::get('/{post}/comments/{comment?}', 'PostController@comments')->name('comments');
    Route::delete('/{post}', 'PostController@destroy')->name('destroy');
});
```

In JavaScript; just get the route by name.

```
axios.get(route('posts.index'));
// http://localhost:8000/posts

axios.get(route('posts.comments', {'post': post.id}));
// http://localhost:8000/posts/1/comments

axios.get(route('posts.comments', {'post': post.id, 'comment': comment.id}));
// http://localhost:8000/posts/1/comments/4

axios.get(route('posts.comments', {'post': post.id, 'comment': comment.id, 'page': 2, 'size': 10}));
// http://localhost:8000/posts/1/comments/4?page=2&size=10

axios.delete(route('posts.destroy', {'post': post.id}));
// http://localhost:8000/posts/1

axios.get(route('posts.index', {'published-at': '2020-09-23 16:42:12'}));
// http://localhost:8000/posts?published-at=2020-09-23%2016:42:12

axios.get(route('posts.index', {'with': ['author', 'comments']}));
// http://localhost:8000/posts?with=author,comments

axios.get(route('posts.index', {'with[0]': 'author', 'with[1]': 'comments'}));
// http://localhost:8000/posts?with[0]=author&with[1]=comments
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity65

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 ~177 days

Recently: every ~240 days

Total

7

Last Release

1107d ago

Major Versions

v1.2.0 → v2.0.02020-09-23

PHP version history (3 changes)v1.0.0PHP ^7.2.5

v1.1.0PHP &gt;=7.0.0

v2.2.0PHP ^7.0|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/0cc99b58d12a288f0fd19099cc3c724ff4df84d978df0e7451b650e8182bc919?d=identicon)[bmatovu](/maintainers/bmatovu)

---

Top Contributors

[![mtvbrianking](https://avatars.githubusercontent.com/u/5412360?v=4)](https://github.com/mtvbrianking "mtvbrianking (24 commits)")

---

Tags

javascriptlaravelpackagerouteslaraveljavascriptrouteslumen

### Embed Badge

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

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

###  Alternatives

[laravel/wayfinder

Generate TypeScript representations of your Laravel actions and routes.

1.7k4.1M69](/packages/laravel-wayfinder)[lord/laroute

Access Laravels URL/Route helper functions, from JavaScript.

8022.0M8](/packages/lord-laroute)[te7a-houdini/laroute

Access Laravels URL/Route helper functions, from JavaScript.

33512.1k](/packages/te7a-houdini-laroute)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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