Skip to main content

What is Wayfinder?

Laravel Wayfinder is a package that bridges a Laravel backend and a TypeScript frontend with zero friction. It auto-generates fully typed TypeScript functions from your controllers and routes, so you can call Laravel endpoints as functions directly from your frontend code. Hardcoded URLs, manually managed route parameters, and hand-syncing backend changes—all of that goes away.
Wayfinder is in Beta (currently v0.1.x). The API may change before v1.0.0. All notable changes are recorded in the CHANGELOG.

Differences between Ziggy and Wayfinder

What is Ziggy?

Ziggy has long been a widely used route helper in the Laravel ecosystem. It exposes Laravel route definitions to JavaScript so you can generate URLs like route('posts.show', { id: 1 }).

Why replace it with Wayfinder?

Because Ziggy handles route names and parameters as strings, its TypeScript integration is limited. Typos in route names or wrong parameter names show up only as runtime errors. Wayfinder is TypeScript-first and generates controller methods as importable functions. In Inertia-based Laravel starter kits (React, Vue, Svelte), Wayfinder is adopted as the standard.

Installation

1. Install the server-side package via Composer

2. Install the Vite plugin via NPM

3. Add the plugin to vite.config.js

With the Vite plugin added, TypeScript files are automatically regenerated whenever PHP files or route files change during dev.

Generating TypeScript definitions

Generate TypeScript files with the wayfinder:generate command.
By default, three directories are generated under resources/js.
Because generated files are fully re-created on every build, add them to .gitignore. Exclude the three directories wayfinder, actions, and routes together.
To change the output location, use the --path option.
You can also generate only actions or only routes.

Basic usage

Importing and using an action

Here’s an example that produces the URL for PostController@show.
Use .url() when you only need the URL.
You can also specify a particular HTTP method.

Passing parameters

Wayfinder functions accept parameters in several forms.
When the route uses key binding (/posts/{post:slug}), pass that value.

Importing a whole controller

You can also import a whole controller and call its methods.
Importing a whole controller defeats tree shaking, so every action ends up in the bundle. Importing individually keeps the final bundle smaller.

Single-action controllers

For single-action (invokable) controllers, call the imported function directly.

Importing named routes

Access by route name using files under routes/.

Query parameters

Every Wayfinder function accepts a query option to add query parameters.
Use mergeQuery to merge with the current URL’s query parameters.

Form variants

For use with traditional HTML forms, generate with --with-form and use the .form variant.

Combining Inertia and Wayfinder

Combining Inertia form helpers with Wayfinder lets you submit forms without writing any URL strings.
It works the same way with the Link component.

Adoption in starter kits

If you create a new project with laravel new and choose React, Vue, or Svelte, you get a setup with Wayfinder configured. The starter kits include:
  • The Composer package laravel/wayfinder
  • The NPM package @laravel/vite-plugin-wayfinder
  • Plugin configuration already applied in vite.config.js
  • Generated directories already added to .gitignore
You can also add it manually to an existing project following the steps above.

Handling reserved words and conflicting method names

Controller methods with the same name as a JavaScript reserved word (like delete or import) get a Method suffix.

Current status (v0.1.x)

The current stable version is provided on the v0.1.x branch. As of March 2026, the latest version is v0.1.15.

v0.1.x main changelog


Next-gen features under development on the next branch

The next branch is developing a substantially expanded next version.
The next branch can be installed with the dev-next constraint, but the API may change significantly. Not recommended for production.

Greatly expanded TypeScript generation

While v0.1.x targets only routes and controller actions, the next version generates all of the following as TypeScript.

Form Request TypeScript type generation

From the above form request, the following type is generated.

Eloquent model type generation

From this model, types are generated in types.d.ts.

PHP Enum → TypeScript conversion

Both the type and constants are generated.

Output directory changes

In v0.1.x, output was split into three directories (actions/, routes/, wayfinder/). In the next version everything lives under resources/js/wayfinder.

Main differences from v0.1.x to next

  • Import paths changed from @/actions/... to @/wayfinder/...
  • The --skip-actions, --skip-routes, and --with-form flags are retired in favor of a configuration file
  • types.ts is renamed to types.d.ts

Summary

Laravel Wayfinder redesigns the “reference Laravel routes from JavaScript” feature Ziggy provided, in a TypeScript-first way. Its approach of importing generated functions delivers big improvements in type safety, IDE support, and tree shaking. Even the current v0.1.x enables type-safe references to routes and controller actions and is adopted by default in Inertia-based Laravel starter kits. The next-branch version under development plans to evolve into a more comprehensive type-safety foundation that also generates Form Requests, Eloquent models, enums, and Inertia page props as TypeScript.

Laravel Wayfinder GitHub

Source code, CHANGELOG, and issues.

Vite Plugin Wayfinder

Detailed configuration options for the Vite plugin.
Last modified on July 13, 2026