Universal Load Functions in Svelte
From the SvelteKit cheat sheet · Data Loading · verified Jul 2026
Universal Load Functions
Load functions that run on both client and server
javascript
// +page.js
export async function load({ params, url }) {
const res = await fetch('/api/post/' + params.id);
const post = await res.json();
return {
post,
title: post.title
};
}
// +page.svelte
<script>
export let data;
</script>
<h1>{data.title}</h1>🔄 Runs on both server and client
🎯 Access to special SvelteKit fetch
📦 Can set response headers and dependencies
⚡ Automatic type safety with TypeScript