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
This allows you to modify response headers or bodies, or bypass SvelteKit entirely (for implementing routes programmatically, for example).
However, IMHP, it's far easier to just copy the folder from project A to project B to get the API working, while utilizing all the features that SvelteKit provides. Which made me wondering, is it possible to make "a route" into a lib that can be imported into a SvelteKit app that'll basically do that?
I used to break my routes into several libs for express.js, and import them per project as needed as such:
is this possible with SvelteKit?
If not, what would the closest "recommended/best-parctice" implementation of that look like for SvelteKit?
IMO that would be great even for +page.svelte routes, allowing to design the login/logout/dashboard/etc route(s) once, and start importing it in projects where/when needed per project; which will contain all the +page.server.ts/+page.ts/+page.svelte files (along with all their components/dependencies) in itself, resulting in less clutter, and whenever I update the files, i just update the lib, and have all the corresponding routes updated in the projects that uses the lib.
I'm also aware that I can achieve that with express if I decided to use the node adapter and import different SvelteKit projects as different routes, importing each's handler and have them assigned to specific route. However, having it built-in will make it seamlessly compatible with the other adapters as well.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
So I have an API:
I'm aware that I can implement a route/API via hooks as mentioned in the docs:
However, IMHP, it's far easier to just copy the folder from project A to project B to get the API working, while utilizing all the features that SvelteKit provides. Which made me wondering, is it possible to make "a route" into a lib that can be imported into a SvelteKit app that'll basically do that?
I used to break my routes into several libs for
express.js
, and import them per project as needed as such:is this possible with SvelteKit?
If not, what would the closest "recommended/best-parctice" implementation of that look like for SvelteKit?
IMO that would be great even for +page.svelte routes, allowing to design the login/logout/dashboard/etc route(s) once, and start importing it in projects where/when needed per project; which will contain all the +page.server.ts/+page.ts/+page.svelte files (along with all their components/dependencies) in itself, resulting in less clutter, and whenever I update the files, i just update the lib, and have all the corresponding routes updated in the projects that uses the lib.
I'm also aware that I can achieve that with express if I decided to use the node adapter and import different SvelteKit projects as different routes, importing each's handler and have them assigned to specific route. However, having it built-in will make it seamlessly compatible with the other adapters as well.
Beta Was this translation helpful? Give feedback.
All reactions