laravel/wayfinder
Generate fully typed TypeScript functions for your Laravel routes and controller methods. Wayfinder lets your frontend call endpoints like normal imports—no hardcoded URLs or manual param syncing. Works with Vite via @laravel/vite-plugin-wayfinder.
Laravel Wayfinder is a highly specialized package designed to bridge Laravel backend APIs with TypeScript frontend applications by auto-generating typed client-side functions for Laravel routes and controller actions. This aligns perfectly with modern full-stack Laravel applications using TypeScript, Vite, or Inertia.js, where API consumers (frontend) need zero-boilerplate access to backend endpoints.
Key architectural strengths:
axios/fetch calls for every endpoint).Route:: definitions).Potential misfit: Projects not using Laravel + TypeScript/Vite (e.g., pure PHP backends, React Native, or non-TypeScript frontends) would gain no value from Wayfinder.
Wayfinder requires minimal setup but imposes strict dependencies:
vite-plugin-wayfinder for real-time updates during development.route:clear before builds to avoid stale route caches.Feasibility score: High (if using Laravel + TypeScript/Vite/Inertia). Complexity: Low to Medium (simple install, but build/deploy pipelines must adapt).
Key integration steps:
vite.config.js with the plugin.php artisan wayfinder:generate (or let Vite handle it).| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Beta Stability | API is not yet v1.0 (subject to breaking changes). | Monitor changelog, test upgrades, and plan for migration if major changes occur. |
| Build Process Risk | Vite plugin ties Wayfinder to Vite’s build lifecycle (could fail silently). | Add CI checks for wayfinder:generate and Vite plugin compatibility. |
| Route Cache Issues | Stale routes in production can break frontend if route:clear is missed. |
Automate route:clear in deploy scripts (e.g., via Laravel Forge/Envoyer). |
| TypeScript Overhead | Generated files are not tree-shakable if importing entire controllers. | Use named imports (e.g., import { show } instead of import PostController). |
| Reserved Word Collisions | JS reserved words (e.g., delete) are renamed to [method]Method. |
Review controller methods for reserved words pre-integration. |
| Query Param Merging | Complex query param logic (e.g., mergeQuery) may have edge cases. |
Test with real-world query strings (e.g., pagination, filtering). |
Critical Risk: Beta API instability is the highest risk. If the project is mission-critical, consider waiting for v1.0 or forking the package for custom stability guarantees.
Frontend Stack:
Deployment Pipeline:
route:clear already automated?wayfinder:generate as a pre-build step?Team Skills:
Alternative Evaluation:
axios + OpenAPI) be more maintainable?Long-Term Viability:
Wayfinder is optimized for the following stack:
| Component | Required? | Notes |
|---|---|---|
| Laravel Backend | ✅ Yes | Uses Laravel’s routing system. |
| TypeScript | ✅ Yes | Generates TypeScript definitions. |
| Vite | ✅ Yes | Vite plugin enables real-time updates. |
| Inertia.js | ❌ No | Optional but highly recommended for form submissions. |
| PHP 8.1+ | ✅ Yes | Laravel 10+ compatibility. |
| Node.js | ✅ Yes | For Vite and NPM dependencies. |
Non-Fit Scenarios:
axios + OpenAPI).wayfinder:generate to build scripts.route:clear in deploy pipelines.axios/fetch to Wayfinder for all endpoints..form() helpers.import { show }) to enable tree-shaking.| Feature | Compatibility | Notes |
|---|---|---|
| Laravel Routing | ✅ Full | Supports named routes, parameters, middleware. |
| Controller Actions | ✅ Full | Generates TypeScript for all public methods. |
| Invokable Controllers | ✅ Full | Supports __invoke() methods. |
| Query Parameters | ✅ Full | Supports query, mergeQuery, and dynamic params. |
| Form Submissions | ✅ Full | Works with Inertia.js and vanilla forms. |
| Inertia.js Integration | ✅ Full | Native support for useForm.submit(). |
| Vite HMR | ✅ Full | Real-time updates during development. |
| Custom Route Parameters | ✅ Partial | May need adjustments for complex binding (e.g., nested objects). |
| Middleware | ❌ Limited | Generated URLs do not include middleware (only route paths). |
| API Resources |
How can I help you explore Laravel packages today?