Allow for content loaders to be used on SSR pages #1067
Replies: 4 comments 4 replies
-
What would be the advantage of a content loader VS just a SDK in this case? Eg. for directus using |
Beta Was this translation helpful? Give feedback.
-
I am somewhat concerned by the proposal without expected boundaries. One of the pain points is MDX. From a content layer point of view, MDX can be rendered only at runtime, so you won't ever see the compiled HTML of a MDX file inside the data store of the content layer. If you allow the content layer to be available in SSR, this means that data coming in a MDX shape needs to be compiled and transformed during the rendering phase. This will make pages very very slow, and we don't want that. So for this proposal to happen, we need to set proper expectations and we should avoid performance pitfalls. |
Beta Was this translation helpful? Give feedback.
-
We using Strapi which is does not have SDK and only a rest API. Most of our pages are static but some require SSR. Though all of them have preview functionality, to view how site would look like before redeploy. That requires SSR. After I upgrading to Astro 5 I had hoped to migrate to the new Content Lake API, but lack of SSR support makes it not possible, better integration with rest api, easier dynamic requests caching, would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
-
Before the content-loader API, I'd say sure, using an SDK is probably best. But the power it gives site-owners to pop a loader in there and forget about it extremely powerful. Especially because the loader essentially only needs a way to list/index and get individual entries. With such a lean API, caching and search indexing could also be introduced without burdening the end-user too much. In comparison, if I wanted to implement content from a CMS SDK (or manually fetching), I'd have to do all the caching and indexing myself without the niceties of having a content-schema defined for my site. My use-cases: I have bluesky posts, github projects and blog posts from my Obsidian directory (on Nextcloud) that I'd love to have added without having to deploy my SSR site. This isn't a must-have feature for me, but reading through the API and docs, I assumed that SSR pages would call getEntry and the loader would get the fresh content and periodically index the data source. While searching for this, I've found many confused people posting issues and questions, so if the plan isn't to enable SSR for loaders, then the docs should probably state that more clearly. |
Beta Was this translation helpful? Give feedback.
-
Summary
Allow for content loaders to fetch collections or external content at runtime.
Background & Motivation
Astro v5 has introduced loaders, which is an amazing system for loading content from content collections or external services at build time. However, a lot of sites have content that changes frequently. Most of the time, this content is hosted externally, so the page doesn't need to rebuild. It would be amazing to have a system that allows for type-safe, cacheable requests in an easy way (that maybe is also available in conjunction with the local API without much configuration)!
I'm a maintainer of StudioCMS, and we'd love to adopt / create a content loader to be used for the CMS, but the limitations for build time only are a bit problematic for people whose content changes often. I think that there's a lot of content sources here that might benefit from runtime loaders.
Goals
Example
You could define a loader like usual:
Then, fetch the content with getCollection in the file:
Perhaps the behavior could be based on the
export const prerender = false | true
directive!Beta Was this translation helpful? Give feedback.
All reactions