데브허브 | DEVHUB | Advent of Svelte 2025 - Day 12: query #javascript #sveltejs #webdevelopment
Remote Functions are a new SvelteKit feature that changes how you interact with data in your applications. Instead of loading data in your load function and passing it down through components, you can now fetch data directly where you need it. Declare a query in a .remote.ts file using the query function from $app/server, then import and call it in any Svelte component.
The function only ever runs on the server, keeping your database access and secrets secure. During server-side rendering it executes as a normal function call, while on the client SvelteKit handles the fetch requests under the hood. Combined with Svelte's async features, you get type-safe, secure, and granular data loading with minimal boilerplate. Use a Standard Schema validator like Zod or Valibot to validate inputs for extra safety.
Read the docs: https://svelte.dev/docs/kit/remote-fu...