Performance: Why SvelteKit handles full-stack routing
This affects page load speed and interaction responsiveness by managing routing on both client and server efficiently.
Using SvelteKit's full-stack routing that handles routing on server and client with partial updates and client-side navigation.Using traditional server-side routing with full page reloads for every navigation, e.g., classic multi-page app with <a href=""> links that reload the entire page.
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Full page reload navigation | High (reloads entire DOM) | Multiple reflows | High paint cost | [X] Bad |
| SvelteKit full-stack routing | Low (updates only changed parts) | Single reflow | Low paint cost | [OK] Good |
src/routes/api/ with .js or .ts extensions define backend endpoints.src/routes/blog/[slug].svelte, what does it do?[slug] in filenames create dynamic routes matching any value in that position.src/routes/blog/[slug].svelte makes a page for each blog post URL like /blog/post1 or /blog/hello.src/routes/api/user.svelte?src/routes/api/ is correct, but the extension must be .js or .ts.load function exported from a page's .js or .ts file to fetch data on the server before rendering.onMount runs only on the client after page loads, so it doesn't fetch data server-side first.load function in the page's .js or .ts file -> Option DPass the test and this pattern moves unknown