This content originally appeared on DEV Community and was authored by Jim Nayzium
I have a load function in my root +layout.js file that is:
export async function load() {
// and all it returns is
return {
prop1: true,
prop2: false,
prop3: "value 3"
};
For the life of me, I cannot do anything in the +layout.svelte file to make these values show up.
export let prop1;
export let prop2;
export let prop3;
console.log("prop1 = " + prop1);
gives me "prop1 undefined" in the console every time!
I have tried deconstructing the export like
let { prop1 } = data;
// and
let { prop1 } = props;
and nothing works... no matter what I do!
Is it because the load function is async? I need it to be async so I can fetch some external api's when it's done, but I was just testing the bare bones to try and understand how things worked.
Any ideas on the load order of
+page.js vs +layout.js
+page.svelte vs +layout.svelte
etc?
This content originally appeared on DEV Community and was authored by Jim Nayzium

Jim Nayzium | Sciencx (2024-07-16T16:11:29+00:00) Confused on +layout.js and +layout.svelte props passed in load() function…. Retrieved from https://www.scien.cx/2024/07/16/confused-on-layout-js-and-layout-svelte-props-passed-in-load-function/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.