PHPackages                             vod/laravel-typed-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. vod/laravel-typed-routes

ActiveLibrary[API Development](/categories/api)

vod/laravel-typed-routes
========================

Typescript route generation and TS client for Laravel

0.0.1(1y ago)02[4 PRs](https://github.com/vodphp/laravel-typed-routes/pulls)MITPHPPHP ^8.2CI passing

Since Apr 13Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/vodphp/laravel-typed-routes)[ Packagist](https://packagist.org/packages/vod/laravel-typed-routes)[ Docs](https://github.com/vod/laravel-typed-routes)[ GitHub Sponsors](https://github.com/Vod)[ RSS](/packages/vod-laravel-typed-routes/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (13)Versions (7)Used By (0)

Laravel Typed Routes - TRPC style routes for Laravel
====================================================

[](#laravel-typed-routes---trpc-style-routes-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3f493a110ed9bf8b5c98334d8186f8f3174d98b23f72db5d79bb06c60401aa92/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f766f642f6c61726176656c2d74797065642d726f757465732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vod/laravel-typed-routes)[![GitHub Tests Action Status](https://camo.githubusercontent.com/79eee9abd4d86c014fcc9645c8136ad629cd3cd03e06376796004c06a5ffe07b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f766f642f6c61726176656c2d74797065642d726f757465732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/vod/laravel-typed-routes/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/765ae7293ff841ecf2e02c5758b434705383495c3111c3fe352c80da047891de/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f766f642f6c61726176656c2d74797065642d726f757465732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/vod/laravel-typed-routes/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/3f97066edb7709363944cee2504eed050c32925219334de1bf347f35f2bb2280/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f766f642f6c61726176656c2d74797065642d726f757465732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vod/laravel-typed-routes)

Introduction
------------

[](#introduction)

This package generates TypeScript types from your Laravel routes, and provides an extensible client for interacting with the routes in a type safe way. It relies on the fantastic Spatie Typescript Transformer under the hood.

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

[](#installation)

You can install the package via composer:

```
composer require vod/laravel-typed-routes
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-typed-routes-config"
```

This is the contents of the published config file:

```
return [
    'output_path' => 'resources/routes.d.ts',
];
```

This defines where the generated types will be output.

Generating Types
----------------

[](#generating-types)

```
php artisan typescript:transform-routes
```

This will generate the types and output them to the path defined in the config file. It's recommended That you run this on save or as a part of your front end dev tooling, so that types are kept up to date.

Setup with Typescript
---------------------

[](#setup-with-typescript)

Setup is easy! In your project, you'll need to setup an rpc client, something as simple as this;

```
/**
 * This puts together the client with the route types. Depending on where you
 * publish the routes, and where this file is, you may need to adjust the import.
 *
 */
import { Routes } from "./types/routes";

//... A basic client, only exposes a basic fetch wrapper;
import { makeBasicClient } from "../../vendor/vod/laravel-typed-routes/js/basicClient";
//... Expects React Query to be installed, and exposes `useQuery` and `useMutation` methods;
import {makeReactQueryClient} from "../../vendor/vod/laravel-typed-routes/js/reactQueryClient";
//... Expects Inertia to be installed, and exposes `useForm` and `visit` methods;
import { makeInertiaClient } from "../../vendor/vod/laravel-typed-routes/js/inertiaClient";
//... Expects React Query and Inertia to be installed, and exposes `useQuery`, `useMutation`, `useForm`, and `usePage` methods;
import { makeFullClient } from "../../vendor/vod/laravel-typed-routes/js/fullClient";

//... Create the client - swap out the client that best suits your needs, or copy any of the clients to extend or modify as you like!
export const routes = makeFullClient();
```

Depending on your project, you will need to adjust the paths for the imports.

Using the client
----------------

[](#using-the-client)

### Route navigation

[](#route-navigation)

This library automatically converts routes to a type path. For example, the following laravel routes would be accessible as;

```
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
Route::get('/example/{id}/hello', [ExampleController::class, 'hello'])->name('example.hello');
Route::put('/example/{id}/update', [ExampleController::class, 'update'])->name('example.update');
```

```
// Routes are automatically converted to a type path.
routes.dashboard.get()
routes.example.id(idGoesHere).hello.get()
routes.example.id(idGoesHere).update.put()
```

The API chosen will determine the methods available. For example, the full client exposes `useQuery`, `useMutation`, `useForm`, and `usePage` methods, so you can use these methods to interact with the routes like this;

### Basic fetch

[](#basic-fetch)

```
const response = await routes.example.id(idGoesHere).hello.get().call({
    message: 'Hello, world!',
});
```

### Inertia

[](#inertia)

```
 //Inside a component
 //use Form to update data on the route;
 const {submit, data, setData} = routes.example.id(idGoesHere).update.post().useForm({
    message: 'hello world',
});

const goToDashboard = () => {
    /**The "visit" method calls the inertia router with the full path,
     * the appropriate method, and any data you want to pass. */
    routes.dashboard.get().visit({success: true});
}
```

### @tanstack/react-query

[](#tanstackreact-query)

```
//Inside a component
//use Query to fetch data from the route;
const { data, isLoading, error } = routes.example.id(idGoesHere).hello.get().useQuery({
    message: 'Hello, world!',
});

//use Mutation to update data on the route;
const { mutate, isLoading, error } = routes.example.id(idGoesHere).update.put().useMutation({
});

mutate({
    message: 'hello world'
})
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Dean McPherson](https://github.com/deanmcpherson)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance67

Regular maintenance activity

Popularity2

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.5% 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

Unknown

Total

1

Last Release

448d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1235347?v=4)[Dean Johnson](/maintainers/Dean)[@dean](https://github.com/dean)

---

Top Contributors

[![deanmcpherson](https://avatars.githubusercontent.com/u/2773950?v=4)](https://github.com/deanmcpherson "deanmcpherson (10 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

laravelvodlaravel-typed-routes

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/vod-laravel-typed-routes/health.svg)

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

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M102](/packages/dedoc-scramble)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816334.1k3](/packages/defstudio-telegraph)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.0k](/packages/simplestats-io-laravel-client)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

44855.7k](/packages/harris21-laravel-fuse)

PHPackages © 2026

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