-
I host my Sveltekit project as a static app using adapter-static. Most of the project is an interactive web application that wouldn't benefit from SSR anyway and hosting a static app is more straight forward. The one exception is the landing page. It doesn't need SSR either but prerendering it would be great to reduce the initial load. It doesnt have any dynamic or user specific elements. In want to prerender the landing page and treat all other pages as a CSR SPA. However, I fail to do so. I set The problem is that the resulting Can someone help me? Am I making a fundamental mistake? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
If you only want to prerender your landing page, then I suggest:
In SvelteKit terms, |
Beta Was this translation helpful? Give feedback.
If you only want to prerender your landing page, then I suggest:
ssr=false
in your root+layout.js
(disable SSR for the whole site)prerender=true
andssr=true
in your root+page.js
(corresponding to the landing page). This will only prerender (and SSR) the landing page. Note that you do needssr
enabled if you want the prerendered page to contain the page's HTML - without enabling SSR, prerendering the page will output an empty shell.In SvelteKit terms,
prerender
only controls whether an HTML file is created for the page at build time. You also need to enablessr
if you want that HTML file to contain the+page.svelte
's corresponding HTML. Since the page is prerendered,ssr
means the s…