I'm struggling with the latest version of SvelteKit, the docs available only works with SSR, and I'm developing a SPA (static page), so, what is the way to pass data from my +layout.svelte
to +page.svelte
?.
The documentation says that with load function from +page.js
(I've already set export const ssr=false
, and I understood that +page.js
is for SSR), but that doesn't work in SPA mode, and if I have the load
function from the layout it's seems not to work.
Additionaly I want to trigger a function from my +page.svelte
that is in the layout page.
Any ideas?
Here is what I tried :
<!-- +layout.svelte -->
<script>
export function load() {
return {
data: { title: 'default title' }
};
}
export let data;
</script>
//+page.svelte
<script>
export let data;
console.log(data.title); //undefined
</script>
The documentation says not to use : <script context="module">
, and I don't want to use the store because I think there must be a better way.