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

Generate fully typed TypeScript functions for your Laravel routes and controller methods. Wayfinder lets your frontend call endpoints like normal imports—no hardcoded URLs or manual param syncing. Works with Vite via @laravel/vite-plugin-wayfinder.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

Laravel Wayfinder is a highly specialized package designed to bridge Laravel backend APIs with TypeScript frontend applications by auto-generating typed client-side functions for Laravel routes and controller actions. This aligns perfectly with modern full-stack Laravel applications using TypeScript, Vite, or Inertia.js, where API consumers (frontend) need zero-boilerplate access to backend endpoints.

Key architectural strengths:

  • Decouples frontend API calls from manual URL/route management (no hardcoded strings, no axios/fetch calls for every endpoint).
  • Type-safe (TypeScript definitions for routes, controllers, and parameters).
  • Seamless integration with Laravel’s routing system (leverages existing Route:: definitions).
  • Supports complex routing (named routes, parameter binding, query params, form submissions).
  • Works with Inertia.js (native integration for form submissions and links).

Potential misfit: Projects not using Laravel + TypeScript/Vite (e.g., pure PHP backends, React Native, or non-TypeScript frontends) would gain no value from Wayfinder.


Integration Feasibility

Wayfinder requires minimal setup but imposes strict dependencies:

  1. Laravel Backend: Must use Laravel’s routing system (no custom API frameworks like FastAPI or GraphQL).
  2. TypeScript/Vite Frontend: Mandatory for generated TypeScript files.
  3. Build Process: Requires vite-plugin-wayfinder for real-time updates during development.
  4. Deployment: Needs route:clear before builds to avoid stale route caches.

Feasibility score: High (if using Laravel + TypeScript/Vite/Inertia). Complexity: Low to Medium (simple install, but build/deploy pipelines must adapt).

Key integration steps:

  1. Install via Composer + NPM.
  2. Configure vite.config.js with the plugin.
  3. Run php artisan wayfinder:generate (or let Vite handle it).
  4. Import generated functions in TypeScript.

Technical Risk

Risk Area Assessment Mitigation Strategy
Beta Stability API is not yet v1.0 (subject to breaking changes). Monitor changelog, test upgrades, and plan for migration if major changes occur.
Build Process Risk Vite plugin ties Wayfinder to Vite’s build lifecycle (could fail silently). Add CI checks for wayfinder:generate and Vite plugin compatibility.
Route Cache Issues Stale routes in production can break frontend if route:clear is missed. Automate route:clear in deploy scripts (e.g., via Laravel Forge/Envoyer).
TypeScript Overhead Generated files are not tree-shakable if importing entire controllers. Use named imports (e.g., import { show } instead of import PostController).
Reserved Word Collisions JS reserved words (e.g., delete) are renamed to [method]Method. Review controller methods for reserved words pre-integration.
Query Param Merging Complex query param logic (e.g., mergeQuery) may have edge cases. Test with real-world query strings (e.g., pagination, filtering).

Critical Risk: Beta API instability is the highest risk. If the project is mission-critical, consider waiting for v1.0 or forking the package for custom stability guarantees.


Key Questions for TPM

  1. Frontend Stack:

    • Is the frontend TypeScript-based? If not, Wayfinder provides no value.
    • Is Vite used? If not, the real-time plugin won’t work (but CLI generation still applies).
    • Is Inertia.js used? If yes, Wayfinder’s Inertia integration is a major win.
  2. Deployment Pipeline:

    • How are Laravel routes cached in production? Is route:clear already automated?
    • Can the build process handle wayfinder:generate as a pre-build step?
  3. Team Skills:

    • Does the team have experience with TypeScript and Laravel routing?
    • Is there comfort with beta-stage packages (or a willingness to fork for stability)?
  4. Alternative Evaluation:

    • Are there existing solutions (e.g., Laravel Sanctum, API Resources, or custom OpenAPI generators) that could serve the same purpose?
    • Would manual API clients (e.g., axios + OpenAPI) be more maintainable?
  5. Long-Term Viability:

    • Is the team committed to Laravel + TypeScript/Vite long-term, or is this a short-term experiment?
    • Are there plans to customize Wayfinder (e.g., extend TypeScript types, add middleware support)?

Integration Approach

Stack Fit

Wayfinder is optimized for the following stack:

Component Required? Notes
Laravel Backend ✅ Yes Uses Laravel’s routing system.
TypeScript ✅ Yes Generates TypeScript definitions.
Vite ✅ Yes Vite plugin enables real-time updates.
Inertia.js ❌ No Optional but highly recommended for form submissions.
PHP 8.1+ ✅ Yes Laravel 10+ compatibility.
Node.js ✅ Yes For Vite and NPM dependencies.

Non-Fit Scenarios:

  • Non-TypeScript frontends (e.g., JavaScript, Vue 2, SvelteKit).
  • Non-Vite build tools (e.g., Webpack, Parcel).
  • Non-Laravel backends (e.g., Symfony, Django, FastAPI).

Migration Path

Phase 1: Evaluation (1-2 weeks)

  1. Set up a proof-of-concept:
    • Install Wayfinder in a staging environment.
    • Generate TypeScript files for 1-2 critical controllers.
    • Test in a TypeScript frontend (e.g., Inertia.js page).
  2. Compare with alternatives:
    • Benchmark against manual API clients (e.g., axios + OpenAPI).
    • Measure developer productivity (time to implement a new endpoint).
  3. Identify edge cases:
    • Test complex routes (nested resources, optional params, query strings).
    • Verify form submissions (Inertia.js integration).

Phase 2: Pilot (2-3 weeks)

  1. Gradual rollout:
    • Start with non-critical endpoints (e.g., admin panels).
    • Replace hardcoded API calls with Wayfinder imports.
  2. Integrate with CI/CD:
    • Add wayfinder:generate to build scripts.
    • Automate route:clear in deploy pipelines.
  3. Monitor stability:
    • Track frontend build failures (e.g., missing routes).
    • Log TypeScript errors in generated files.

Phase 3: Full Adoption (3-4 weeks)

  1. Replace all API clients:
    • Migrate from axios/fetch to Wayfinder for all endpoints.
    • Update form submissions to use .form() helpers.
  2. Optimize imports:
    • Use named imports (e.g., import { show }) to enable tree-shaking.
    • Avoid importing entire controllers unless necessary.
  3. Document patterns:
    • Create internal guidelines for Wayfinder usage (e.g., parameter passing, query params).
    • Train developers on debugging generated files.

Compatibility

Feature Compatibility Notes
Laravel Routing ✅ Full Supports named routes, parameters, middleware.
Controller Actions ✅ Full Generates TypeScript for all public methods.
Invokable Controllers ✅ Full Supports __invoke() methods.
Query Parameters ✅ Full Supports query, mergeQuery, and dynamic params.
Form Submissions ✅ Full Works with Inertia.js and vanilla forms.
Inertia.js Integration ✅ Full Native support for useForm.submit().
Vite HMR ✅ Full Real-time updates during development.
Custom Route Parameters ✅ Partial May need adjustments for complex binding (e.g., nested objects).
Middleware ❌ Limited Generated URLs do not include middleware (only route paths).
API Resources
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata