Does SvelteKit relies on NodeJS?

Viewed 630

SvelteKit provides a "skeleton" for multi-page app, of which two features are particularly interesting for me: 1) a routing system (src/routes); 2) server-side rendering.

My question is: does SvelteKit rely on NodeJS? I use Go as backend server, which works well with VueJS frontend. I just simply copy the output of webpack (the dist folder) to my go source tree and compile it into a single executable.

Does that work with SvelteKit?

EDIT

Background: I am primarily a Go programmer. Before I know Svelte, I purely uses Bootstrap + vanilla JS for frontend development. I've tried VueJS, but give up. The purpose of this question is to ask: is it worth to learn SvelteKit or just Svelte?

In another word, SSR is "nice to have" for me. However if the "routing" architecture does not work without Node, then I feel I'd better just go with Svelte, or, is there any other reason to choose SvelteKit?

2 Answers

I think you mean static rendering from

I just simply copy the output of webpack

If you want to do static rendering with SvelteKit, install @sveltejs/adapter-static@next and plug it into your svelte.config.js as import adapter from '@sveltejs/adapter-static';.

You may have to set an extra property, prerender, in the config, that way Svelte knows to do prerendering for any logic in the page, so it can build correctly.

An example svelte.config.js file that does this:

import adapter from '@sveltejs/adapter-static';

/** @type {import('@sveltejs/kit').Config} */
const config = {
    kit: {
        adapter: adapter(),
        prerender: {
            default: true
        }
    }
};

export default config;

That way, when you do npm run build in the directory containing the project, it will output to the build folder.

The server-side routing and rendering features of SvelteKit are tied to its implementation, which is in Node.

In particular, server-side rendering of Svelte components will unavoidably depend on Node at some level, because the Svelte compiler is written in TypeScript.


SvelteKit is intended to be an all-in-one solution for web applications, but you can configure it instead to output a pre-rendered static site (see LeoDog896's answer), with client-side routing intact.

It should be trivial to set up a Go server to serve the static site so that routing works as expected. The only missing piece would be SSR, which is strongly tied to SvelteKit's own server implementation.

Related