4 ms·
The common mistake teams make getting started with server-side rendering for React is thinking that your entire backend has to be contained in a single JavaScri
by paxys 5y ago
The common mistake teams make getting started with server-side rendering for React is thinking that your entire backend has to be contained in a single JavaScript bundle. Instead, use any language you want to set up your APIs and business logic. Then set up a fully independent pool of servers running Node.js whose only job is SSR. This setup skips over every problem the author mentions.
- chrisco255 5y agoThe newest versions of Next.js have API routes that are independently deployed as serverless functions, so they do not interfere with the SSR instance.
- quickthrower2 5y agoYeah, I have recently learned Next.js WITH that and so I haven't experienced the pain points. Also using Next.js with something like Firestore (etc.) is also helpful. Next.js seem to recommend delegating in their documentation (e.g. need a scheduler? Use Github actions).
- notriddle 5y agoWhen I realized what the OP was describing, it honestly caught me off-guard. I had never heard of anyone attempting to colocate their API server and their Fastboot/Next.JS server in the same Node instance. Node is single-threaded. If you try to run lots of different things within the same Node VM, a runaway CPU-bound loop in your frontend can wind up causing the backend to lock up. Bad failure mode. If your API server is separate from your Frontend server, you don't just make maintaining it more reasonable (the "server colored functions" are now a strict subset of the "client colored functions"). You also get operational flexibility: run the Frontend server in an edge function system [1], while running the API server alongside your DBMS. Isn't that what edge functions are for? [1]: https://news.ycombinator.com/item?id=31084301 https://news.ycombinator.com/item?id=31084301