sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
18.11k stars 1.84k forks source link

Support for pre-rendering individual svelte components (partial pre-rendering) #11089

Open sacarvy opened 7 months ago

sacarvy commented 7 months ago

Describe the problem

Currently, how the rendering works is on page level, not on component level specific! Sometimes, components such as Header, Footer or Sidebar are just needed to get re-rendered once during the time of build and never again!

Describe the proposed solution

With RSC we have cache, something similar to that maybe we can have

<script>
// from component file
export const prerender = true;
</script>
<header></header>

Alternatives considered

Alternative in front of me is to utilise the pre-render option at the page level

Importance

nice to have

rbozan commented 3 months ago

Hi, I'm wondering what the usual way is to "prerender" for example a footer with external data attached to it? I'm currently loading data in a global +layout.server.ts, but I notice that every time a page request is made clientside the __data.json of that page is filled with that global data, even though that data does not change. So it sends unneeded data. I'm wondering if there's a better way.