A deep dive into Laravel Wayfinder, the TypeScript-first replacement for Ziggy now bundled with Inertia-based starter kits. Covers the difference from Ziggy, installation, code generation, all major usage patterns, and a look at what’s coming in the next branch.
Laravel Wayfinder is a package that bridges your Laravel backend and TypeScript frontend with zero friction. It automatically generates fully typed TypeScript functions from your controllers and routes, so you can call Laravel endpoints directly as functions from your frontend code.No more hardcoded URLs, no more manually managing route parameters, no more keeping the frontend in sync with backend changes by hand.
Wayfinder is in beta (currently v0.1.x). The API may change before v1.0.0 is released. All breaking changes are recorded in the CHANGELOG.
Ziggy has been a widely used route helper in the Laravel ecosystem for years. It exposes Laravel route definitions to JavaScript so you can generate URLs like route('posts.show', { id: 1 }).
Ziggy represents route names and parameters as strings, which limits TypeScript compatibility. A typo in a route name or a wrong parameter name only surfaces as a runtime error.Wayfinder takes a TypeScript-first approach and generates controller methods as importable functions.
Feature
Ziggy
Wayfinder
Route reference
route('posts.show', { id: 1 })
import { show } from "@/actions/..."
Type safety
Limited type definitions
Full TypeScript types
IDE support
Weak autocomplete
Full autocomplete and type checking
Tree shaking
All routes in bundle
Only used routes bundled
Generation timing
Injected at runtime
Statically generated at build time
Wayfinder ships as the default in Inertia-based Laravel starter kits (React, Vue, and Svelte).
Run the wayfinder:generate Artisan command to generate TypeScript files.
php artisan wayfinder:generate
By default, three directories are created under resources/js:
resources/js/├── actions/ # Functions for controller actions│ └── App/Http/Controllers/│ └── PostController.ts├── routes/ # Functions for named routes│ └── post.ts└── wayfinder/ # Type definition files └── types.ts
The generated files are fully regenerated on every build, so it’s a good idea to add them to .gitignore. Exclude all three directories: wayfinder, actions, and routes.
To change the output directory, use the --path option:
You can import the whole controller and call methods on it:
import PostController from "@/actions/App/Http/Controllers/PostController";PostController.show(1);PostController.index();
Importing the entire controller disables tree shaking, so all actions are included in the bundle. Import actions individually to keep your final bundle size small.
Combining Inertia’s form helper with Wayfinder lets you submit forms without writing a single URL string:
import { useForm } from "@inertiajs/react";import { store } from "@/actions/App/Http/Controllers/PostController";const form = useForm({ name: "My Post" });form.submit(store()); // submits to POST /posts
The Link component works the same way:
import { Link } from "@inertiajs/react";import { show } from "@/actions/App/Http/Controllers/PostController";const Nav = () => ( <Link href={show(1)}>View post</Link>);
Laravel Wayfinder redesigns the “call Laravel routes from JavaScript” experience that Ziggy provided, but with TypeScript-first architecture. By generating importable functions, it delivers full type safety, IDE autocomplete, and tree shaking out of the box.The current v0.1.x release already handles routes and controller actions with complete type safety, and ships as the default in Inertia-based Laravel starter kits. The next branch is evolving toward a far more comprehensive type-safe foundation — covering Form Requests, Eloquent models, Enums, Inertia page props, and more.