Replies: 7 comments 6 replies
-
What do you mean by less flexible and designing your own components? I'm also curious regarding this topic as I have unsuccessfully tried pairing Laravel and Django with Svelte in the past (mostly due to my lack of knowledge). |
Beta Was this translation helpful? Give feedback.
-
@dghubble I am using sveltekit as a SPA with my "own" backend. (you have to use @sveltejs/adapter-static and |
Beta Was this translation helpful? Give feedback.
-
I do not think that you can easily do composition stuff in pure Svelte what you can do with sveltekit (https://kit.svelte.dev/docs/advanced-routing#advanced-layouts) But maybe you do not need this. Furthermore, of course I can pick an extra lib to do routing but I prefer an "official" one which is supported in the future and is rather powerful (data loading etc) |
Beta Was this translation helpful? Give feedback.
-
FWIW, I've found that all of the latest frameworks like Kit are not meant to integrate with existing web apps that have their own routing and request handling. Kit, Next, Nuxt, Astro, Vite + vite-plugin-ssr all assume their framework will handle figuring out which (page) component to render and the building of props to render that component. I'm also coming from a backend dev experience where we have an app framework like Express or Django or Rails and a template that the framework passes data into to render into HTML before responding with 2xx/4xx/5xx. I've built my own "use Svelte like a traditional server-side templating engine" integration with Vite but it was a mess. Now, the closest I've found to ideal is Vite + vite-plugin-ssr. But it has it's own challenges. I think Kit/Next/etc. are good for new projects that you want to run on Vercel/Netlify/Lambda. This probably means there's another backend that runs in your own VPC that can connect to your private resources (DB, queues, etc.) But I've struggled to see how they can easily integrate with an existing web app. |
Beta Was this translation helpful? Give feedback.
-
If you configure your app to use the deno adapter, you could use deno's FFI (foreign function interface) to implement code in Rust or whatever other language, and call it from within a sveltekit server file. There's also NAPI-RS for Rust and Node.js so it's more limited but it has auto typescript generation based on your rust types which is kinda nice. |
Beta Was this translation helpful? Give feedback.
-
If you proxy the requests properly, then you can use a traditional backend in the same host using a judicious use of You only have one architecturally weird thing in our current implementation: The frontend process makes credentialed requests to the backend process on localhost. Ideally this would go via a IPC socket. Using SvelteKit without disabling all of it's features gives you pre-rendered pages with API requests to a traditional backend living in the same host while also allowing client-side navigation. This setup works for us. |
Beta Was this translation helpful? Give feedback.
-
Ben has a PR open to address this https://github.com/sveltejs/kit/pull/13444/files would love if people could give it a read and provide some feedback |
Beta Was this translation helpful? Give feedback.
-
We have traditional backend apps that use Svelte (not SvelteKit) working very well. Existing services (non-Javascript, Go, Rust, etc.) render pages, serve the
bundle.js
file, and use plenty of Svelte components (e.g. top-level App and a whole tree of components, pass props, etc.), along with a router like tinro.Enter SvelteKit, which seems to be recommended. First, Vite wants to serve the html (the real server has additional logic that's needed) and generates a bunch of
js
chunks by default (disable that to get a singlebundle.js
to put into anindex.html
https://vitejs.dev/guide/backend-integration.html). Next, SvelteKit seems to focus a lot on SSR+server.js
functions - but we're not planning to use JS server side at all and end up disabling anything SSR related (https://www.npmjs.com/package/@sveltejs/adapter-static). SvelteKit's file-based router with +layout.svelte's and +page.svelte files (look at the path to figure out which page) seems less flexible (we end up mostly designing our own components). I don't mean this to be critical, more just figuring out whether SvelteKit is the right fit for the traditional backend use case.I feel like we're mostly fighting against Vite and SvelteKit in these experiments, turning off features. What am I missing?
Is SvelteKit actually aiming to be the best way to build all Svelte apps? Or is it aiming for a narrower set of use cases? It seems designed for Netlify style apps, where frontend/backend are in Javascript/Typescript, a platform abstracts away the backend, and the whole app is pretty much a SvelteKit app. For those using traditional backends, where Svelte is just a small piece of the larger whole, does SvelteKit have a value proposition over plain Svelte?
Context: We're mostly backend/systems engineers, who like Svelte, but confused by SveltKit.
Beta Was this translation helpful? Give feedback.
All reactions