Loading data server side/prerendered in a non page component? #10998
-
Hi, I was wondering how you would handle this scenario: I have a complex search component, which offers many filtering options. When searched, it redirects to the results page. This component is used a few times throughout the app and is not an own page (no What I thought of (just a dream, maybe that totally not possible) would be a Is something like this possible/planned? Did I overlook/not understand some docs? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Create a +layout.server.ts file at the root of your application and return the data through the load function. This makes the data available to every page. https://kit.svelte.dev/docs/load#layout-data Then, use the page store to access that data directly in your search component without having to pass it in as a prop. |
Beta Was this translation helpful? Give feedback.
Create a +layout.server.ts file at the root of your application and return the data through the load function. This makes the data available to every page.
https://kit.svelte.dev/docs/load#layout-data
Then, use the page store to access that data directly in your search component without having to pass it in as a prop.
https://kit.svelte.dev/docs/load#$page-data