Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Wayfinder Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

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:

    • Type Safety: Generates strongly typed TS functions for routes/actions, improving developer experience and reducing runtime errors.
    • Zero-Boilerplate API Calls: Enables direct invocation of Laravel endpoints as if they were local functions (e.g., show(1) instead of axios.get('/posts/1')).
    • Inertia.js Integration: Seamlessly integrates with Inertia’s useForm and Link components, reducing coupling between frontend and backend URL management.
    • Form Support: Generates <form> attributes dynamically (e.g., action, method, _method), simplifying traditional form submissions.
  • Non-Fit Scenarios:

    • Non-TypeScript Frontends: If the frontend uses plain JavaScript or doesn’t leverage TypeScript, Wayfinder’s value diminishes.
    • Headless APIs: For APIs consumed by non-web clients (e.g., mobile apps, server-to-server), Wayfinder’s frontend-focused features (e.g., form helpers) are irrelevant.
    • Legacy Codebases: Applications with highly dynamic routes (e.g., generated via middleware or runtime logic) may require custom parsing logic.

Integration Feasibility

Wayfinder integrates via two primary mechanisms:

  1. PHP Artisan Command: php artisan wayfinder:generate scans Laravel routes/controllers and outputs TS definitions to resources/js/wayfinder/.
  2. Vite Plugin: @laravel/vite-plugin-wayfinder regenerates definitions during dev builds and watches for changes.
  • Prerequisites:

    • Laravel 10+ (tested up to Laravel 13).
    • Vite as the frontend build tool (required for the plugin).
    • TypeScript in the frontend stack.
    • Optional: Inertia.js for enhanced form/Link integration.
  • Compatibility Risks:

    • Route Caching: Wayfinder relies on Laravel’s route model binding and naming conventions. Custom route resolvers or non-standard naming may require adjustments.
    • Reserved Keywords: Controller methods named after JS reserved words (e.g., delete, class) are auto-renamed (e.g., deleteMethod), which may need frontend refactoring.
    • Dynamic Routes: Routes with complex logic (e.g., middleware-based URL generation) may not generate accurately without customization.
  • Customization Points:

    • Output Path: Configurable via --path flag.
    • Selective Generation: Skip actions/routes with --skip-actions/--skip-routes.
    • Form Support: Opt-in via --with-form flag.
    • Query Parameters: Extensible via the options object in TS calls.

Technical Risk

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.

Key Questions for Stakeholders

  1. Frontend Stack:

    • Is the frontend TypeScript-based? If not, what’s the alternative for API URL management?
    • Does the team use Inertia.js? If yes, Wayfinder’s form/Link integrations add significant value.
  2. Backend Complexity:

    • Are routes conventionally named (e.g., post.show) or heavily customized?
    • Do controllers use non-standard parameter binding (e.g., custom resolvers)?
    • Are there dynamic route segments (e.g., generated via middleware)?
  3. Development Workflow:

    • Is the team comfortable with auto-generated files (can be .gitignored)?
    • What’s the CI/CD pipeline like? Wayfinder adds a build step but is lightweight.
  4. Long-Term Viability:

    • Is the team committed to Laravel 10+ for the foreseeable future?
    • Are there plans to adopt v1.0.0 when released (currently in beta)?

Integration Approach

Stack Fit

Wayfinder is optimized for the following stack:

  • Backend: Laravel 10+ with routes defined in routes/web.php or API resources.

  • Frontend:

    • TypeScript (required for generated definitions).
    • Vite (required for the plugin; supports other bundlers via custom setup).
    • Inertia.js (optional but recommended for form/Link integrations).
    • Frameworks: React, Vue, Svelte, or vanilla TS (no framework-specific dependencies).
  • Anti-Patterns:

    • Non-Vite Build Tools: Webpack or Parcel would require manual integration (e.g., custom watchers).
    • JavaScript Frontends: Loses type safety benefits.
    • Monolithic Backends: If the backend is not Laravel, Wayfinder is useless.

Migration Path

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.

Compatibility

  • Laravel:
    • Supported: Routes, controllers, named routes, model binding, and form requests.
    • Unsupported: Custom route resolvers, non-standard URI generation logic.
  • Frontend:
    • Supported: TypeScript, Vite, Inertia.js, React/Vue/Svelte.
    • Unsupported: Plain JS, Webpack, non-Vite bundlers (without custom setup).
  • Edge Cases:
    • Reserved Keywords: Auto-renamed (e.g., deletedeleteMethod).
    • Nested Routes: Handled via barrel files (e.g., actions/App/Http/Controllers/).
    • Query Parameters: Merged dynamically at runtime.

Sequencing

  1. Backend Preparation:
    • Ensure routes/controllers follow Laravel conventions (e.g., named routes, standard parameter binding).
    • Test php artisan route:list and php artisan wayfinder:generate in a staging environment.
  2. Frontend Setup:
    • Install Vite plugin and configure vite.config.js.
    • Add wayfinder:generate to package.json scripts:
      {
        "scripts": {
          "dev": "vite",
          "build": "vite build && php artisan wayfinder:generate"
        }
      }
      
  3. Incremental Rollout:
    • Start with non-critical routes (e.g., static pages).
    • Gradually replace API calls in components (e.g., axios.getimport { show } from "@/actions/...").
  4. Inertia Integration (Optional):
    • Replace manual useForm/Link URL construction with Wayfinder helpers.
    • Example:
      // Before
      <Link href={`/posts/${post.id}`}>View</Link>
      
      // After
      import { show } from "@/actions/PostController";
      <Link href={show(post.id).url}>View</Link>
      

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport