Registry / web-framework / vite-plugin-kit-routes

vite-plugin-kit-routes

JSON →
library1.0.3jsnpmunverified

vite-plugin-kit-routes is a Vite plugin for SvelteKit that generates a typed route helper file ($lib/ROUTES) from your file system routes. It provides autocompletion, type safety, and avoids typos by letting you reference routes via a type-safe route() function. The latest stable version is 1.0.3, released as part of the KitQL ecosystem. It requires SvelteKit ^2.4.0 and Vite ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0. Compared to manual route strings or other route generation tools, it integrates directly as a Vite plugin, generates TypeScript types automatically, and updates the route file on save. Release cadence follows monthly updates alongside other KitQL packages.

npm install vite-plugin-kit-routes
INSTALL
IMPORT
SIG · VITE-PLUGIN-KIT-RO
V
vite-plugin-kit-routes
web-frameworkjavascriptv1.0.3
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

kitRoutes
✓ import { kitRoutes } from 'vite-plugin-kit-routes'
✗ import kitRoutes from 'vite-plugin-kit-routes'
Named export since v1.0.0. Default import is not available.
route
✓ import { route } from '$lib/ROUTES'
✗ import { route } from 'vite-plugin-kit-routes'
route() is generated in $lib/ROUTES by the plugin. Do not import from the package directly.
Routes
✓ import type { Routes } from '$lib/ROUTES'
TypeScript type for route parameters, generated in $lib/ROUTES. Useful for parameterized routes.

Shows how to add the plugin to Vite config and use the generated route function in a SvelteKit component.

// vite.config.(js|ts) import { sveltekit } from '@sveltejs/kit/vite'; import { kitRoutes } from 'vite-plugin-kit-routes'; import { defineConfig } from 'vite'; export default defineConfig({ plugins: [ sveltekit(), kitRoutes() ] }); // In a Svelte component or .ts file: <script lang="ts"> import { route } from '$lib/ROUTES'; const url = route('/about'); // typed string </script> <a href={url}>About</a>
Debug
Known issues
gotchaThe route() function is generated in $lib/ROUTES, not imported from vite-plugin-kit-routes. If you try to import from the package, you will get a module not found error.
fix
Ensure $lib/ROUTES exists after running the plugin. Import route from '$lib/ROUTES'.
affects: >=1.0.0
breakingvite-plugin-kit-routes requires @sveltejs/kit ^2.4.0 and Vite ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0. Using older versions will cause compatibility issues.
fix
Update dependencies: npm install @sveltejs/kit@^2.4.0 vite@^5.0.0
affects: >=1.0.0
deprecatedEarlier versions (pre-1.0) used a different export pattern. Default import is now deprecated.
fix
Use named import: import { kitRoutes } from 'vite-plugin-kit-routes'
affects: <1.0.0
Errors
Common errors & fixes
Error: Cannot find module '$lib/ROUTES' or its corresponding type declarations.
The plugin has not generated the $lib/ROUTES file yet, or the file is out of sync.
fix
Ensure the plugin is properly added to vite.config and restart the dev server (npm run dev). The file is generated on startup.
[vite] Internal server error: [plugin:vite-plugin-kit-routes] kitRoutes is not a function
Using a default import instead of a named import, or the package is not installed.
fix
Use named import: import { kitRoutes } from 'vite-plugin-kit-routes'. Also check that the package is installed: npm i -D vite-plugin-kit-routes
TypeError: route is not a function
Importing route from the wrong module or the generated file is missing.
fix
Import route from '$lib/ROUTES' (not from the package). Ensure the plugin is running and the file exists.
Error: [plugin:vite-plugin-kit-routes] Unsupported SvelteKit version. Requires @sveltejs/kit >=2.4.0
Installed @sveltejs/kit version is too old.
fix
Upgrade @sveltejs/kit: npm install @sveltejs/kit@^2.4.0
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
@sveltejs/kitrequiredPeer dependency: required for SvelteKit route generation.
viterequiredPeer dependency: required as a Vite plugin.
Agent activity
20 hits · last 30 days
node
18
OpenAI (training)
1
Resources