laravel/wayfinder
Laravel Wayfinder bridges your Laravel backend and TypeScript frontend by generating fully-typed, importable TypeScript functions for your controllers and routes—no more hardcoded URLs or manual syncing. Includes a Vite plugin that regenerates definitions automatically during builds and dev server r...
routes.ts constants file, or a custom codegen script. All of those are ongoing maintenance liabilities that drift silently from the backend. Wayfinder is first-party Laravel, MIT, and generated output is disposable (gitignored, rebuilt every build) — the build-vs-buy call is close to free.--with-form / .form() variants let you ship plain HTML <form> submissions (including _method spoofing) without a client-side fetch layer. This supports decisions like "do we need a JS-heavy SPA form component, or can this page be a form post?" — useful for scope-cutting on low-interactivity screens.query / mergeQuery options (including null to strip a parameter) make it trivial to model filters, pagination, and sort state as URL state. This supports the product decision to make list views shareable/bookmarkable rather than held in client memory.useForm().submit() and <Link href> integration), Laravel + React/Vue with any data-fetching layer, multi-page apps with a smattering of JS, and teams whose frontend and backend are maintained by different people (the generated types become the handshake).Adopt when most of these are true:
@laravel/vite-plugin-wayfinder makes regeneration automatic on file change; without Vite you're scripting php artisan wayfinder:generate yourself.Look elsewhere or wait when:
ForcedRoot domain handling). That is normal for a young codegen tool, but it tells you edge cases are still being found.route:cache staleness issue is the sharpest operational edge here: if your deploy runs php artisan optimize before npm run build, generation runs against a stale route table and Vite fails with missing-module errors. This must be a deliberate, documented step (route:clear → npm run build), not an afterthought. Teams with rigid or heavily cached deploy pipelines should scope that work before committing.PostController rather than named action functions defeats tree-shaking. The guidance exists, but it's a footgun you must codify in lint rules or conventions.Net read: the case for adoption is strong for Inertia/TS Laravel teams and weak-to-premature everywhere else. The two genuine risks are beta API churn and the route-cache deploy ordering — both manageable, neither free.
For executives — one paragraph: Laravel Wayfinder is a free, MIT-licensed, first-party Laravel package that automatically generates typed TypeScript functions from our backend routes and controllers. In plain terms: the frontend can no longer build against a URL that doesn't exist. Route mistakes that today show up as production 404s and broken links become build-time errors caught before deploy. It's a small, contained addition — no new service, no vendor contract, no data migration — and the generated code is disposable, so there's no long-term lock-in.
For engineering — the substance: Install laravel/wayfinder plus the @laravel/vite-plugin-wayfinder Vite plugin; the plugin regenerates types during dev-server file changes and on build. Generated output (resources/js/{wayfinder,actions,routes}) is gitignored and rebuilt every build, so there's no review noise and no merge conflicts. We get fully typed action functions with flexible argument shapes (positional, keyed object, nested, route-model-binding aware e.g. {post:slug}), .url() / .head() / .form() variants, typed query and mergeQuery options for URL-state filtering, and first-class named-route imports which sidestep the multi-route-to-one-action edge case. Inertia integration is documented and direct: form.submit(store()) and <Link href={show(1)}>. Known edges we should decide on up front: the package is beta (pin the version, expect minor churn); importing an entire controller defeats tree-shaking, so we standardize on per-action and named-route imports; and deploy scripts must run php artisan route:clear before npm run build to avoid generating against a stale route cache.
The decision being asked for: approve a time-boxed pilot on one TS/Inertia surface plus a documented deploy-script change, with success measured by (a) zero frontend-originated 404s from route drift in that surface, and (b) removal of any hand-maintained route constant file.
How can I help you explore Laravel packages today?