by udkl · 3y ago · 0 comments
I have a netxjs based discussion forum in development. Is it as straightforward as issuing a command to pre-render and then the site re-hydrates via Apollo on it's own ?
Say you have a useEffect that calls an API: maybe firebase or parse. That useEffect only gets run on the client. For the server side render: it runs the react code based on the initial props and takes that first rendering and creates the static html from that. When that static html is run on the browser it will run react and subsequent renders can update the dom.
For HN for example, you could prerender much of the content including latest comments and get Next to keep it up to date, cache invalidating as necessary. Basically have it rebuild static pages as posts are made. Then use fetch calls or maybe sockets to get the very latest posts and keep it up to date, even live updates if you wish.
ISR is the jargon here: https://nextjs.org/docs/basic-features/data-fetching/increme...
It is a bit like a mirror of what HN does. HN will use caching so that if you are logged out you get fast renders of pages. Instead of caching, you are pregenerating and keeping it up to date.