I’m fairly new to Redwood, mainly been using Gatsby recently.
I took a look at prerendering and I’m not totally sure if it meets the needs I have for this project. I would need to be able to statically generate pages using a CMS (with i18n), and also have some dynamic stuff on the frontend that would take advantage of Redwood Cells/API and auth.
Is this something that’s been done with Redwood before? Or would I have to run my own implementation of SSG and translations?
EDIT: I’ve seen a thread about using both Gatsby and Redwood for a project, but the main issue is that even the dynamic pages with Redwood would still have copy/text/forms that are generated by the CMS.
Welcome @davidli3100! My understanding is that right now, you can prerender entirely static pages (no data fetching during build) only. They are rehydrated client-side in the browser, and you can do whatever you want with them there in terms of dynamic data fetching. What you can’t do is build for example a static page that’s a list of all the records in a collection, where you have to fetch the collection when you build the static page server(less)-side.
My understanding also is that the prerender package might also include dynamic data fetching during static generation at some point in the future. There was a message at one point that said the core team felt like it was a critical thing to do right, and won’t be in the v1 release.
I guess I’ll just download everything from the CMS as a JSON file as a pre-build script and “dynamically” fetch the data that way. Feels a little clunky but I think Redwood is worth the extra hassle
Note: If you want to do mutations, check your CMS docs. For Contentful, they have separate delivery (read) and a management (write) SDKs – which would use different API keys.
@dthyresson that’s a really great idea. I did it with Hasura just playing around and following a tutorial. Two headless CMS vendors that provide native GraphQL APIs are Sanity and GraphCMS. Sanity has a JS client. I don’t see one for GraphCMS.
You could also do the html rendering in a serverless function and leverage Netlify’s On-Demand Builders
This would be cached. until another deploy.
That is what they propose to do for large sites – so that content is not generated at build time.
You’d use a redirect proxy (with a slug or other identifier) to your serverless function that would fetch the CMS content, render the html and return the response.
And then you could have a hook that would feed back the translations and data into presentational components for pre-rendering (pretty sure JSON is included in pre-rendering as a static asset?). Gonna take a look at Netlify On-demand builders though, it seems promising