-
Notifications
You must be signed in to change notification settings - Fork 32
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
Enhance hybrid rendering to prerender all pages by default #539
Comments
I'm excited to see progress on this! Since creating this original proposal, I've realised that support from the editor tooling will be needed to make this feature more accessible to users. An indicator will be needed to communicate to the user what output mode is set for a particular page - perhaps an icon in the corner or a message in the status bar at the bottom. This will be even more important if the There was also some discussion around adding an Either way, I'm excited to see this idea returned to the spotlight and hope to see it shipping shortly! |
output: 'static'
build
Updated OP to remove any references to any specific implementation (leaving that for the RFC) and also to better reflect the current thinking around goals/non-goals for this feature based on some convos that Nate and I have had. |
As for actual implementation ideas: the idea that Nate and I were leaning towards IIRC (alluded to by @zadeviggers above) was the idea of a new The reasoning for the name is that this would be seen as a hybrid approach mixing qualities from all-static SSG (
This idea always comes up because it sounds great on the surface ("isn't This was the reason that we ultimately shipped hybrid rendering as a feature of The other solution proposed was to turn
cc @hippotastic would love your help on this one! I still believe that either proposal here would be relatively straight-forward to implement! |
Thanks for the explainer @FredKSchott! As soon as I laid eyes upon the second option, I fell in love - it's just so right. The one thing I might change here would be to rename |
I'd be okay shipping either one! FWIW I personally prefer the first one because I'd like to optimize for the easiest migration story of Another option is to support both, where |
The idea that resonated the most with me is this: type Config = {
ouput:
| "static"
| "server"
| ({ mode: "static" } | { mode: "server"; prerenderDefault: boolean });
} It's similar to what you suggested with string values mapping to defaults for the object configuration, but without adding the extra This is a good option because it will encourage users to slowly migrate their projects to the object config option without introducing a breaking change. All that being said, your point about users wanting to add their first server route without too much hassle is very valid, so I'm still not sure what the best choice would be. |
It may be worth looking at #116 , if opt-in for SSR is being discussed, as it would be more granular than the current and proposed full-page toggle. ---
import CurrentTime from "./foo.astro"
import SlowComponent from "./bar.astro"
import SlowToBuildSvelte from "./baz.svelte"
import SmallComponent from "./bax.svalte"
---
<body>
<CurrentTime server:dynamic /> <!-- Will render on request -->
<SlowComponent /> <!-- Statically redered -->
<SlowToBuildSvelte client:load /> <!-- Statically redered but still reactive -->
<SmallComponent client:load server:dynamic /> <!-- Rendered on request and reactive -->
</body> But it would be a maintenance burden and almost definitely a new render mode though, so may not be worth it. |
Can you explain this a bit more? I'm not sure I completely follow. Is this more about how Astro's build is implemented or is there a conceptual difference that you're seeing? |
Here's some of the differences between
There are probably other things I can't think of right now. |
Closing as this is completed and in stable. |
Body
Summary
Make an enhancement to Astro's Hybrid Rendering support to make pre-rendering the default for all pages, and opt-out instead of opt-in.
Background & Motivation
Currently, pre-rendering pages in SSR is possible thanks to Hybrid Rendering. However, this uses
output: 'server'
which defaults all pages to server-rendered. This can be annoying for mostly-static sites that then need to addexport const prerender = true;
to most pages.One common use-case (mentioned in the original pre-rendering RFC) is a fully static site with a few server-side api routes. The current implementation requires a migrating user to add
output: 'server'
to their configuration and then manually addexport const prerender = true
to each.astro
page in theirsrc/pages
directory before continuing.This was originally discussed in the pre-rendering RFC. However it was ultimately removed because it was assumed that this would require a new third internal implementation (
static
andserver
(SSR) already exist today) which was considered too much of a maintenance burden to take on.Goals
export const prerender = true
output
mode in the user-facing configuration API is okay, as long as it leverages the existingstatic
orserver
internal build implementation.Non-Goals
The text was updated successfully, but these errors were encountered: