For creating a SvelteKit SPA app, we first need to set up SvelteKit to have all the pages pre-rendered. For this, for every +page.svelte we need to add a +page.server.ts or a +page.server.js with the following –

export const prerender = true;
export const ssr = true;

This will create the corresponding pages for each route. For example, if we have a URL like example.com/about, we will have an about.html page getting created.

However, putting the build folder directly under a simple nginx config doesn’t work. Since the URL does not have an .html extension, even if those pages are there, nginx doesn’t show them.

Continue reading