{"id":22938,"library":"vite-plugin-ziggy","title":"vite-plugin-ziggy","description":"Vite plugin that auto-generates TypeScript route type definitions for Laravel Ziggy based on your Laravel route files. Current stable version is 0.3.0, released with a focus on seamless integration with Laravel development workflows. Key differentiators: automatic regeneration on route file changes, support for Sail, route filtering (only/except), and optional sail/php execution. Alternatives require manual type generation or separate build steps.","status":"active","version":"0.3.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","vite","vite-plugin","ziggy","typescript"],"install":[{"cmd":"npm install vite-plugin-ziggy","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-ziggy","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-ziggy","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Vite plugin, requires Vite as peer dependency","package":"vite","optional":false}],"imports":[{"note":"Default export; ESM-only usage recommended in Vite config files. CommonJS require works in CJS contexts, but Vite configs are typically ESM.","wrong":"const ziggy = require('vite-plugin-ziggy');","symbol":"default (ziggy)","correct":"import ziggy from 'vite-plugin-ziggy';"},{"note":"Add to tsconfig.json types array, not import statement. This references the generated type declaration file at node_modules/vite-plugin-ziggy/routes.","wrong":"import './node_modules/vite-plugin-ziggy/routes';","symbol":"type declaration","correct":"// In tsconfig.json types: [\"vite-plugin-ziggy/routes\"]"},{"note":"ZiggyRoute is declared globally in the generated types file. Do not import from the package directly.","wrong":"import { ZiggyRoute } from 'vite-plugin-ziggy';","symbol":"ZiggyRoute type","correct":"// Generated type is available globally as ZiggyRoute"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport ziggy from 'vite-plugin-ziggy';\n\nexport default defineConfig({\n  plugins: [\n    ziggy({\n      sail: true,\n      group: 'api',\n      url: process.env.APP_URL ?? 'http://localhost',\n      only: ['admin.*'],\n      except: ['debugbar.*'],\n      types: true,\n      typesOnly: false,\n    }),\n  ],\n});\n\n// tsconfig.json\n{\n  \"compilerOptions\": {\n    \"types\": [\"vite/client\", \"vite-plugin-ziggy/routes\"]\n  }\n}\n\n// After running vite, route types are auto-generated.\n// Use in any TS file:\nconst routeName: ZiggyRoute = 'admin.users.index';\nroute(routeName, { id: 1 }); // typed parameters","lang":"typescript","description":"Shows minimal Vite plugin setup with common options and tsconfig type inclusion for generated route types."},"warnings":[{"fix":"Add node_modules/vite-plugin-ziggy/routes.d.ts to .gitignore.","message":"Generated types file is placed in node_modules; ensure it's not committed to version control.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Rename global type using plugin config or avoid duplicate global names.","message":"ZiggyRoute type is declared globally; conflicts with other packages using same global name may occur.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set custom path in plugin configuration to prepare for migration.","message":"v1.0.0 will change default output path from node_modules/vite-plugin-ziggy/routes to a project-level location.","severity":"breaking","affected_versions":">=0.0.0 <1.0.0"},{"fix":"Explicitly set typesOnly: false if you need both types and route data.","message":"Option 'typesOnly' defaults to true but in v0.4.0 will default to false to generate both types and actual route data.","severity":"deprecated","affected_versions":"==0.3.0"},{"fix":"Ensure 'php artisan' or 'sail' is available in PATH.","message":"Requires Laravel project with artisan route:list command accessible. Sail option uses 'sail' shell command.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.3.0':28 'altern':58 'auto':9 'auto-gener':8 'automat':42 'base':18 'build':65 'chang':47 'current':24 'definit':14 'develop':38 'differenti':41 'execut':57 'file':23,46 'filter':52 'focus':32 'generat':10,62 'integr':35 'javascript':67 'key':40 'laravel':16,21,37 'manual':60 'only/except':53 'option':55 'plugin':3,6,71 'regener':43 'releas':29 'requir':59 'rout':12,22,45,51 'sail':50 'sail/php':56 'seamless':34 'separ':64 'stabl':25 'step':66 'support':48 'type':13,61 'typescript':11,73 'version':26 'vite':2,5,68,70 'vite-plugin':69 'vite-plugin-ziggi':1 'workflow':39 'ziggi':4,17,72","created_at":"2026-04-27T17:07:52.862553+00:00","updated_at":"2026-04-27T17:07:52.862553+00:00","problems":[{"fix":"Add \"vite-plugin-ziggy/routes\" to the 'types' array in tsconfig.json.","cause":"TypeScript cannot locate generated type declaration because tsconfig.json 'types' array is missing.","error":"Cannot find module 'vite-plugin-ziggy/routes' or its corresponding type declarations."},{"fix":"Use default import: import ziggy from 'vite-plugin-ziggy';","cause":"Incorrect import style: using named export instead of default export.","error":"TypeError: ziggy is not a function"},{"fix":"Disable sail: false or install Laravel Sail.","cause":"Sail option enabled but Laravel Sail is not installed or not in PATH.","error":"The term 'sail' is not recognized as the name of a cmdlet, function, script file, or operable program."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/vite-plugin-ziggy","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}