- What Laravel versions does Wayfinder support?
- Wayfinder is designed for Laravel 10.x and 11.x. Check the package’s Composer requirements and changelog for specific version compatibility, as the beta API may evolve. Always test upgrades in a staging environment.
- Can I use Wayfinder without Vite or Inertia.js?
- Yes, but with limitations. The CLI command `php artisan wayfinder:generate` works standalone, but real-time updates during development require the Vite plugin. Inertia.js integration is optional but provides seamless form handling and link generation.
- How do I handle route parameters in TypeScript with Wayfinder?
- Wayfinder auto-generates TypeScript types for route parameters, including dynamic segments and query strings. For example, a route like `/posts/{id}` generates a function with a typed `id` parameter. No manual type definitions are needed.
- Does Wayfinder support API resources or form requests?
- Yes, Wayfinder generates TypeScript functions for all Laravel route actions, including those using API resources or Form Request validation. The generated types reflect the request payload structure, ensuring type safety on the frontend.
- How do I customize the generated TypeScript output path?
- Use the `--path` flag with the `wayfinder:generate` command to specify a custom output directory, such as `php artisan wayfinder:generate --path=app/types/wayfinder`. The default is `resources/js/wayfinder`.
- Will Wayfinder break if I update Laravel routes frequently?
- No, Wayfinder regenerates TypeScript files on every build or when you run `php artisan wayfinder:generate`. However, ensure your deployment pipeline includes `route:clear` to avoid stale route caches breaking frontend calls.
- Can I use Wayfinder with React or Vue instead of Inertia.js?
- Absolutely. Wayfinder generates standalone TypeScript functions for API calls, which work with any frontend framework (React, Vue, Svelte, etc.). Inertia.js integration is optional and adds convenience for form submissions and links.
- How do I handle reserved JavaScript words in controller methods?
- Wayfinder automatically renames controller methods that conflict with JavaScript reserved words (e.g., `delete` becomes `deleteMethod`). Review the generated files for any edge cases, but this is handled out-of-the-box for most scenarios.
- Is Wayfinder compatible with Laravel Sanctum or Passport for authentication?
- Yes, Wayfinder generates typed functions for authenticated routes. If your routes require authentication (e.g., Sanctum/Passport), the generated TypeScript functions will include the necessary headers or tokens automatically.
- What are the risks of using Wayfinder in production before v1.0?
- The beta API may introduce breaking changes. Mitigate risks by monitoring the changelog, testing upgrades in staging, and automating `wayfinder:generate` in CI/CD pipelines. For mission-critical apps, consider forking the package or waiting for v1.0.