3 ms·
Can you explain this please ? I have a netxjs based discussion forum in development. Is it as straightforward as issuing a command to pre-render and then the s
by udkl 4y ago
Can you explain this please ?
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 ?
- weird-eye-issue 4y agoForums are dynamic so no you can't fully static deploy that
- quickthrower2 4y agoYes this only works when you use JS to implement anything dynamic, user specific, requiring up to date (up to the second) data and so on. You can keep the static content fairly up to date. 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/incremental-static-regeneration 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.
- udkl 4y agoThanks, this was useful.
- quickthrower2 4y agoI have not used apollo but to explain: 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.