Conversation
🦋 Changeset detectedLatest commit: 64a4c75 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| It's likely that at least some routes of your app can be represented as a simple HTML file generated at build time. These routes can be [_prerendered_](/docs/appendix#prerendering). | ||
|
|
||
| Prerendering happens automatically for any page with the `prerender` annotation: | ||
| Prerendering happens automatically for any `+page` or `+server` file with the `prerender` annotation: |
There was a problem hiding this comment.
should we add JS here to clarify that you can't add it to +page.svelte?
| Prerendering happens automatically for any `+page` or `+server` file with the `prerender` annotation: | |
| Prerendering happens automatically for any `+page` or `+server` JS file with the `prerender` annotation: |
There was a problem hiding this comment.
I was hoping the code sample would make it clear — adding JS muddies the waters a bit in the case where people are using TypeScript
There was a problem hiding this comment.
There are some other places where it's +page/layout with the .js ending. We should probably make that consistent, either adding the .js file always or never (except for when we introduce it).
|
|
||
| ```js | ||
| /// file: +page.js/+page.server.js/+server.js | ||
| export const prerender = 'auto'; |
There was a problem hiding this comment.
now that I've seen the docs and understand what this option does, I'll throw another name into the ring. how about 'partial'?
There was a problem hiding this comment.
I think I prefer auto — partial doesn't have the right connotation to me, it sounds like the page is being partially prerendered
dummdidumm
left a comment
There was a problem hiding this comment.
Looks good! Will adjust the minor suggestions I made myself and merge to get the related PR in good state
|
|
||
| ```js | ||
| /// file: +page.js/+page.server.js | ||
| /// file: +page.js/+page.server.js/+server.js |
There was a problem hiding this comment.
I was confused for a bit because I think "what kind of folder names are these?". Maybe instead +page.js, or +page.server.js, or +server.js?
There was a problem hiding this comment.
Skipping this for now, seing that it's like this for all others as well.
| export const prerender = false; | ||
| ``` | ||
|
|
||
| Routes with `prerender = true` will be excluded from manifests used for dynamic SSR, making your server (or serverless/edge functions) smaller. In some cases you might want to prerender a route but also include it in the manifest (for example, you want to prerender your most recent/popular content but server-render the long tail) — for these cases, there's a third option, 'auto': |
There was a problem hiding this comment.
It took me a little while to understand why this works - why can I prerender AND SSR a route - until I thought "oh yes with [slug]". I don't know how to express this better, but maybe we can come up with something later.
Migration
General
+serverpages can be prerendered, too now, by adding theexport const prerender = ..option to them. By default they are not prerendered, but any+serverpage that is referenced from a prerendered page inherits theprerenderoption of that page unless explicitly set otherwise. This might lead to a situation where you now get a "Cannot prerender a +server file with POST, PATCH, PUT, or DELETE" error. To fix it, addexport const prerender = false;to the+serverfile where it happens, or move the mutative methods in a different file.adapter-static
Instead of only checking the default for prerendering, the actual found routes are now checked for prerendering. If one of them is not prerenderable, an error is thrown unless you set the
fallbackoption. If you get this error now, adjust your code so thatfallbackoptionPR description
#6356.
prerender = truefrom generated manifests'auto'(prerender, but also include in manifests) as a value, alongsidetrue(only prerender, exclude from manifests) andfalse(never prerender, include in manifests)prerender = falseorprerender = 'auto'(or unknown, in the case of endpoints that are never fetched during prerendering)Not in scope for this PR: removing
config.kit.prerender.defaultand using defaults from+layout[.server].jsfiles. That can be added to #6197 once this is merged.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. All changesets should bepatchuntil SvelteKit 1.0