2

I am familiar with svelte.js for client side wherein client and server are disconnected and all communication is via AJAX calls. However, I have a question whether shared hosting without node installation can deploy a sveltekit app?

Any comments are welcome.

1 Answer 1

3

Yes and no. You can serve static sveltekit pages generated with @sveltejs/adapter-static. If you want SSR or to use server side load functions, endpoint, or any other 'backend' feature of sveltekit you will need to use a different adapter. For that, you will need @sveltejs/adapter-node, or another adapter. For supported environments see this page of the docs. So yes, you will need a javascript runtime (probably nodejs) to use all of sveltekit's features.

Sign up to request clarification or add additional context in comments.

8 Comments

Just to build on Caleb's accurate answer, adapter-static I feel is a bit of misnomer, your pages can still call and retrieve data from remote endpoints, it's just that those endpoints will not be part of your app, but rather be provided by 3rd-party APIs or by a separately deployed backend.
So, API routes can be made in php backend. Then what is the advantage of svelte-kit over svelte in that case? Does that mean that API backend and server hosting the frontend will have to be necessarily different?
Thanks! SPA build from svelte loads all of bundle together and then does client side rendering. I have a situation where a preexistent backend in PHP (Slim4) exists. So, if I use adapter-static, I loose SSR. But will sveltekit give me any advantage in terms of faster loads and SEO?
For SEO I would be inclined to say yes since for instance you'll be able to leverage dynamic page names (the /routes/foo/[bar] syntax) giving you more meaningful URLs -and that's just one example. Using layouts (and sub-layouts) is also better for handling shared elements across your pages, etc. Overall, I consider there are many advantages to using Kit over regular Svelte. Also, if at some point you decide to integrate your backend into the project, having your frontend already built with Kit will make the transition a lot easier.
Also, because each page will have its own JS bundle and scoped CSS, the payloads tend to be smaller (= better performance). Page-scoped CSS does not prevent you from using global CSS on top, if you so desire.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.