Download the PHP package vod/laravel-typed-routes without Composer
On this page you can find all versions of the php package vod/laravel-typed-routes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vod/laravel-typed-routes
More information about vod/laravel-typed-routes
Files in vod/laravel-typed-routes
Package laravel-typed-routes
Short Description Typescript route generation and TS client for Laravel
License MIT
Homepage https://github.com/vod/laravel-typed-routes
Informations about the package laravel-typed-routes
Laravel Typed Routes - TRPC style routes for Laravel
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
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
This defines where the generated types will be output.
Generating Types
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 is easy! In your project, you'll need to setup an rpc client, something as simple as this;
Depending on your project, you will need to adjust the paths for the imports.
Using the client
Route navigation
This library automatically converts routes to a type path. For example, the following laravel routes would be accessible as;
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
Inertia
@tanstack/react-query
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Dean McPherson
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-typed-routes with dependencies
illuminate/contracts Version ^10.0||^11.0||^12.0
spatie/laravel-package-tools Version ^1.16
spatie/laravel-typescript-transformer Version *