Svelte · Junior · Question 52 of 76

How does a page get data from its load function?

// +page.js
export function load({ params }) {
  return { post: getPost(params.slug) };
}

<!-- +page.svelte -->
<script>
  let { data } = $props();
</script>
<h1>{data.post.title}</h1>

Explanation

Data from layouts' load functions is merged into data as well.

Further reading

Problem with a question

Svelte · Junior · question 52

Test yourself

Take the Svelte · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz