Why use export let data
when $page.data
can do the same?
#7898
-
I usually use exported data to build +page.svelte and The two are not the same, but in the end you can also just do everything with I'm probably missing some important nuance, but I can't really find it in the docs. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Followup up on this useful thread, if I have a |
Beta Was this translation helpful? Give feedback.
If you use $page.data, you dont get type completion of your load function in the editor
But you do if you use
export let data: PageData
in your+page.svelte
file, you doIts a convenience for us, the developers, functionally.. there is not much difference between the 2. $page is a store, so it can be called deep inside components without prop drilling, so generally to make your life easier, use $page when you are in components, and
export let data:PageData
when you are in a+page.svelte
file.