You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we are trying to build a larger app in SvelteKit and one of the pain points we stumbled on was that we couldn't figure out a way for a library to export a whole route.
In our scenario we need to divide the application in several pieces (we call them "modules" -- not to be confused with ESM modules) which consist of frontend pieces as well as quite some backend logic.
Imagine something like a multi-step dialog where you put in data on each step, then data is reloaded from the server and you proceed to the next step and finally data is commited. The developer would create the frontend dialogs but also his backend API routes.
Currenlty this is quite painful: there doesn't seem to be a simple way for the module to export it's whole sub-routes.
Describe the proposed solution
The workarounds we tried was to create a +server.ts with GET and POST handlers that are exported from the module -- this is bad for various resons, we loose data-preloading and invalidation mechanics and it's a painful to develop routes "in a vacuum" without type-safety and devalues serialization of higher-order data types (Dates, etc).
Another workaround was to export all the "load" functions separately and import them in various +page.server.svelte / +layout.server.svelte files. This was even more terrible, now the main app needs to know how the module wants it's subroutes to be organized and has to make sure the routing replicates the expected layout. This is very error prone, there is no way to validate that the routes the main app creates are the ones the module expects.
Alternatives considered
For now, the best workaround we have is to use another WinterCG compliant API handler -- again with all the problems mentioned above (no preloading + invalidation) and we have to add a separate software. However we get type-safe data fetching and the module can define it's own routes.
Importance
would make my life easier
Additional Information
I would love it if it was possible for SvelteKit to mount a complete sub-route at a specific endpoint, similar to the functionality other routes provide:
express, koa and oak have .use
Elysia has .mount
fastify has .register
hono has .route
So it would like to see the SvelteKit router to be able to do something similar -- a way to mount a "sub-app" at a defined entrypoint, preferably even at multiple different entrypoints and preferably as exports from other projects/NPM modules.
In my mind, this would be relevant for any library that provides frontend and backend functionality -- like plug-in mail clients or more complex auth systems (i.e. OIDC) and probably for any larger app that would be developed by multiple teams.
Are there any thoughts on this in the community?
The text was updated successfully, but these errors were encountered:
Describe the problem
Currently we are trying to build a larger app in SvelteKit and one of the pain points we stumbled on was that we couldn't figure out a way for a library to export a whole route.
In our scenario we need to divide the application in several pieces (we call them "modules" -- not to be confused with ESM modules) which consist of frontend pieces as well as quite some backend logic.
Imagine something like a multi-step dialog where you put in data on each step, then data is reloaded from the server and you proceed to the next step and finally data is commited. The developer would create the frontend dialogs but also his backend API routes.
Currenlty this is quite painful: there doesn't seem to be a simple way for the module to export it's whole sub-routes.
Describe the proposed solution
The workarounds we tried was to create a +server.ts with GET and POST handlers that are exported from the module -- this is bad for various resons, we loose data-preloading and invalidation mechanics and it's a painful to develop routes "in a vacuum" without type-safety and devalues serialization of higher-order data types (Dates, etc).
Another workaround was to export all the "load" functions separately and import them in various +page.server.svelte / +layout.server.svelte files. This was even more terrible, now the main app needs to know how the module wants it's subroutes to be organized and has to make sure the routing replicates the expected layout. This is very error prone, there is no way to validate that the routes the main app creates are the ones the module expects.
Alternatives considered
For now, the best workaround we have is to use another WinterCG compliant API handler -- again with all the problems mentioned above (no preloading + invalidation) and we have to add a separate software. However we get type-safe data fetching and the module can define it's own routes.
Importance
would make my life easier
Additional Information
I would love it if it was possible for SvelteKit to mount a complete sub-route at a specific endpoint, similar to the functionality other routes provide:
.use
.mount
.register
.route
So it would like to see the SvelteKit router to be able to do something similar -- a way to mount a "sub-app" at a defined entrypoint, preferably even at multiple different entrypoints and preferably as exports from other projects/NPM modules.
In my mind, this would be relevant for any library that provides frontend and backend functionality -- like plug-in mail clients or more complex auth systems (i.e. OIDC) and probably for any larger app that would be developed by multiple teams.
Are there any thoughts on this in the community?
The text was updated successfully, but these errors were encountered: