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
Add support for SSR #1255
base: main
Are you sure you want to change the base?
Add support for SSR #1255
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🦋 Changeset detectedLatest commit: 0487488 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Hello! Thank you for opening your first PR to Starlight! ✨ Here’s what will happen next:
|
For anyone that want to try this out on their website to check for problems you can install it with:
|
Probably blocked by withastro/astro#9392, due to that bug any project using Starlight with SSR cannot add any other page to the project as everything will be overridden by Starlight's |
Any updates on that? I have to patch package to add |
This depended on withastro/astro#9439, released on 4.2. It's on my pipe to come back to this and make any necessary changes. I'll probably ping people to review it by next Tuesday. |
waiting for this to be released 🙏 |
@Fryuni. Thanks for your support. I have a tested this new changes and tried to deploy to Cloudflare. I was able to deploy it. But there is a catch, I have to get a Workers Paid subscription. Because in cloudflare there is limit for function file size (1 MiB), but the basic starlight function size is around 8-9 MiB (output = "server"). In Workers paid plan, the limit is 10 MiB. So i was able to deploy it. But for someone planning to implement this in a much bigger project which uses more server side capabilities, this might be something to look out for. But once again, Thank you very much @Fryuni |
Yeah, I don't think there is much for us to do on that front. In server output mode the entire content and all the tooling to render the content has to be shipped into a single function to be processed on each request, so that is a lot of data. |
Hey folks! Thanks for this effort @Fryuni. I just wanted to let you know that I shipped a website with your patched version from I might reserve some time to take a look at the ins and outs of this PR and provide some assistance in getting it merged into the main branch. |
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
Hey @marcelovicentegc, thanks for the ping! There is not much blocking this PR; it is just a big change, and the team hasn't had the time to review it yet. @delucis any chance this gets closer to the top of your to-do list? 🥺 |
Summary
Add configuration for not prerendering Starlight pages.
This enables using components with SSR logic on Starlight pages, whether in the content or as component overrides.
Notes
Double index
To do this without triggering multiple warnings, there are now two
.astro
pages for the index entrypoint:index.astro
is always prerendered and usesgetStaticPaths
andAstro.props
to receive information about the route.indexSSR.astro
that is never prerendered and retrieves the information about the route from the dynamic route parameter.Route parameter indexing
To make the SSR rendering efficient, a lookup map for all the content was created using the parameter that will be received from the dynamic route.
Pagefind
Pagefind indexing requires access to the HTML file generated by the routes, but those are not available when building for SSR, so Pagefind is not supported when using SSR.
The solution that I implemented for this is that when both SSR and Pagefind are enabled for Starlight, the content of the docs is pre-rendered for indexing but not included in the final build. The final content served will be from SSR, but the index will be built from that static rendering.Default behavior
Starlight will default to the same as any other Astro page, prerendering when the output mode is not defined, when it isstatic
, and when it ishybrid
. When the output mode isserver
, Starlight will default to SSR.Starlight previously didn't build at all when the site had output mode set toserver
, so the different default is not, AFAICT, a breaking change.Starlight will default to prerender pages, which differs from the default for Astro pages. This is to maintain compatibility and because docs pages are most commonly not dynamic. Users must set
prerender: false
in their Starlight configuration to enable on-demand docs page rendering. At the moment, this applies to all Starlight pages. Future work could be done to support SSR on only some of the pages.TODO
child_process
logic to build plugins (git information)