-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mark endpoints as prerenderable #4093
Comments
Would this mark all defined HTTP methods for that endpoint as needing to be prerendered? Do we need more granularity than that? |
On most platforms, it goes to the filesystem first — if there's a |
I think that’s probably confusing. If there are two things which are true by default, then saying one is true doesn’t usefully imply the other is false. The option should likely say it disables the opposite. Maybe |
I think this would be a great feature, especially for apps where a part of the data from let's say a CMS changes only occasionally. |
Im calling an endpoint from a load function in a svelte layout, to fetch a dynamic navigation structure from a headless CMS. Having this endpoint being prerendered at build time would be excellent. Btw, I think opt in to endpoint prerender at build time is important. Some endpoints might fetch data from sources with dynamic content. |
This would be a huge performance boost for those managing content inside Svelte Kit (with e.g. MDSveX), where only a new build would actually require endpoints to update their content. Game changer for listing content, RSS feeds, sitemap, etc. |
One thing that just occurred to me: in order to have prerendered endpoints that serve non-prerendered pages, we'll need the prerenderer to render every page it crawls, not just the prerenderable ones. In practice I think that's totally fine — we find the bits we need to prerender as a side-effect of prerendering the bits that we then discard — but it needs to be noted since it's technically a breaking change. |
From #4942: we might also need a way to declare that an endpoint should never be prerendered (i.e. prerendering |
Quick proposal to solving this: pattern-based config to include/exclude crawled URLs. |
Right now |
Closed via #6392 |
Describe the problem
If an endpoint loads data from the filesystem...
...then in most environments it will won't work in production — it's only suitable for prerendering. SvelteKit doesn't know that, and will include the endpoint in the built app. This is bad for two reasons:
We're experiencing this right now with https://kit.svelte.dev/docs/nope.
Describe the proposed solution
If we could mark the endpoint with
export const prerender = true
, just like we do with pages, we could avoid including the endpoint in the deployed app.The semantics are slightly different to
export const prerender = true
in pages, where it means 'you can prerender this page' as opposed to 'you can ONLY prerender this endpoint', but I think that's probably fine.Alternatives considered
No response
Importance
would make my life easier
Additional Information
No response
The text was updated successfully, but these errors were encountered: