laravel/wayfinder
Zero‑friction Laravel → TypeScript bridge. Wayfinder auto‑generates fully typed, importable TS functions for your routes and controller actions, letting you call endpoints like normal functions—no hardcoded URLs, parameter guessing, or manual syncing.
Laravel Wayfinder is a highly complementary package for Laravel applications using TypeScript-based frontends (e.g., Inertia.js, Vue, React, or vanilla TS). It bridges the backend and frontend by automatically generating TypeScript definitions for Laravel routes and controller actions, eliminating manual URL hardcoding and reducing API drift risk.
Key Fit Criteria:
show(1) instead of axios.get('/posts/1')).useForm and Link components, reducing coupling between frontend and backend URL management.<form> attributes dynamically (e.g., action, method, _method), simplifying traditional form submissions.Non-Fit Scenarios:
Wayfinder integrates via two primary mechanisms:
php artisan wayfinder:generate scans Laravel routes/controllers and outputs TS definitions to resources/js/wayfinder/.@laravel/vite-plugin-wayfinder regenerates definitions during dev builds and watches for changes.Prerequisites:
Compatibility Risks:
delete, class) are auto-renamed (e.g., deleteMethod), which may need frontend refactoring.Customization Points:
--path flag.--skip-actions/--skip-routes.--with-form flag.options object in TS calls.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Beta Stability | High | Monitor changelog for breaking changes; test in staging before production. |
| Route Parsing Errors | Medium | Validate generated TS files against actual API responses; use --skip-actions for problematic controllers. |
| Build Overhead | Low | Vite plugin only regenerates changed files; minimal impact on dev builds. |
| TypeScript Strictness | Medium | Ensure frontend TS config (strict: true) to catch mismatches early. |
| Inertia.js Dependency | Low | Core Wayfinder works without Inertia; opt-in features require it. |
| Performance Impact | Low | Generated files are static; runtime overhead is negligible. |
Frontend Stack:
Backend Complexity:
post.show) or heavily customized?Development Workflow:
.gitignored)?Long-Term Viability:
Wayfinder is optimized for the following stack:
Backend: Laravel 10+ with routes defined in routes/web.php or API resources.
Frontend:
Anti-Patterns:
| Phase | Action Items | Dependencies |
|---|---|---|
| Assessment | Audit routes/controllers for compatibility (e.g., reserved keywords, dynamic segments). | Backend team. |
| Pilot | Generate Wayfinder files in a non-production branch and test with a subset of routes/actions. | Frontend/Backend devs. |
| Integration | 1. Install laravel/wayfinder and @laravel/vite-plugin-wayfinder.2. Update vite.config.js to include the plugin.3. Configure wayfinder:generate in package.json scripts. |
Vite, TypeScript, Laravel CLI. |
| Frontend Adoption | Replace hardcoded URLs with Wayfinder imports (e.g., import { show } from "@/actions/..."). |
Frontend team. |
| Inertia Optimization | (Optional) Replace useForm/Link manual URL construction with Wayfinder-generated helpers. |
Inertia.js. |
| CI/CD Update | Add wayfinder:generate to build scripts (if not using Vite’s dev server). |
CI pipeline. |
delete → deleteMethod).actions/App/Http/Controllers/).php artisan route:list and php artisan wayfinder:generate in a staging environment.vite.config.js.wayfinder:generate to package.json scripts:
{
"scripts": {
"dev": "vite",
"build": "vite build && php artisan wayfinder:generate"
}
}
axios.get → import { show } from "@/actions/...").useForm/Link URL construction with Wayfinder helpers.// Before
<Link href={`/posts/${post.id}`}>View</Link>
// After
import { show } from "@/actions/PostController";
<Link href={show(post.id).url}>View</Link>
How can I help you explore Laravel packages today?