âš¡How to - vite-plugin-kit-routes
Never be out of sync with your routes again 🥳
💡
It's very early, things might change! 😉
By default, no Configuration is needed, it will just infer as much as it can from your project. Then you will be able to narrow down types & search params.
Installation
npm i -D vite-plugin-kit-routes
Configuration
Add the plugin like this:
vite.config.js
import { kitRoutes } from 'vite-plugin-kit-routes'
/** @type {import('vite').UserConfig} */
const config = {
plugins: [
// This is the plugin to add
kitRoutes()
]
}
export default config
It will create a file ./src/lib/ROUTES.ts
at the start of your dev server & any update of any of
your +page.svelte
| +server.ts
| +page.server.ts
.
Side Notes
-
You can run prettier at the end of the process with something like:
kitRoutes({ post_update_run: 'npm exec prettier ./src/lib/ROUTES.ts -- -w' })
-
You can specify a searchParam for some paths
kitRoutes({ extend: { PAGES: { site: { explicit_search_params: { limit: { type: 'number' } } } } } })
- You can narrow down the type of params
kitRoutes({ extend: { PAGES: { site_id: { params: { id: { type: 'string' } } } } } })