SSR explained in SvelteKit

Hi all,

I recently started working with Svelte and created a small app with SvelteKit in order to understand better the framework. I have a few questions about this framework to witch I haven’t found any direct answers on any source/documentation and maybe you can help me with some answers/explanations. So here it goes:

  1. SvelteKit has SSR and in the documentation it says: “All server-side code, including endpoints, has access to fetch in case you need to request data from external APIs.”
    a. What code is server side rendered besides endpoints and how it decides this? All the code from scripts from svelte pages runs on client side or some of it runs on server side?
    b. In order to make use of SSR locally you need an adapter for it or svelte starts a server on its own?
    c. How the SSR works on a prod environment like Netlify for example. The netlify adapter is used for SSR (running the endpoints in a netlify function) ? If a netlify adapter is not provided, how/where would the endpoints run?
  2. If I want to use custom netlify functions in a sveltekit project what configurations are needed (besides netlify.toml and netlify adapter) in order for netlify to recognize the functions from inside the functions directory?
  3. What is the difference here between SSR and prerendering? SSR is used only for endpoints and other js code and prerendering is used for generarting the html to send it to the client which will then be hydrated, with the compiled js code, also sent to the browser?

Hope is not too much and the questions are not too trivial. Still trying to understand better the JS frameworks to keep up with the progress in the JS world.

Thanks!

4 Likes