Svelte & SvelteKit (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)
SvelteKit `load` Architecture: `+page.server.ts` vs `+page.ts`.
senior LevelSystem DesignSvelte 5
In Simple Words:
+page.server.ts(PageServerLoad): Runs only on the server. Has direct access to private database connections, Node.js libraries, and private secrets. Returns serialized JSON data.+page.ts(PageLoad): Universal load function. Runs on the server during initial SSR, and then runs directly on the client during subsequent client-side navigations, making direct fetch calls.