Ziggy adds a JavaScript route() helper that mirrors Laravel’s named routes, so front-end code can build URLs and query strings from the same route names and parameters as PHP.
Overview
Ziggy bridges Laravel’s routing layer and client-side JavaScript. After Composer installation, a Blade @routes directive can expose route definitions to the page so a global route() function generates paths from route names and parameters, including query arguments and default parameter values.
The JavaScript Router object supports checking the current route, testing whether a route exists, and reading current route parameters. Route-model binding works with objects passed as parameters, including custom binding keys. TypeScript types and Artisan generation can enable autocompletion and optional strict route name checking.
Integrations include Vue and React plugins or hooks, NPM packaging for SPAs without a Laravel vendor tree, and Artisan commands to dump configuration to files or JSON for separate front-end repos. Route lists can be filtered with only, except, or group settings in config/ziggy.php, and CSP-friendly output modes exist for strict content security policies.
Ziggy can return its configuration from a Laravel API route for remote clients. TLS termination behind proxies may require Laravel trusted proxy configuration so generated URLs use the correct scheme.
Key features
- JavaScript route() like Laravel
- Route-model binding support
- Vue and React integrations
- TypeScript route name types
- Configurable route filtering
- NPM package for separate front ends
- CSP-compatible route output
- Query parameter handling
Use cases
- Laravel SPA URL generation
- Axios links to named backend routes
- Shared routes in Vue or React
- API apps exposing Ziggy config as JSON