In the root +layout.server.ts the load is defined like this:
import type { LayoutServerLoad } from './$types';
export const load: LayoutServerLoad = () => {
return { year: 2024 };
};
And the in the root +layout.ts the load is defined like this and ssr is set to false (important!):
import type { LayoutLoad } from './$types';
export const ssr = false;
export const load: LayoutLoad = ({ data }) => {
return { year: data.year };
};
When going to a route that exists data contains the expected year property. But when going to a route that does not exist data is suddenly null.
This does not happen if ssr is set to true.
So to summarize:
LayoutServerLoad if ssr is true ✅LayoutServerLoad if ssr is false ✅LayoutServerLoad if ssr is true ✅LayoutServerLoad if ssr is false ❌