DEV Community

Discussion on: How to server-side render React, hydrate it on the client and combine client and server routes

Collapse
 
rahulatgit profile image
rahulAtGit

Hey that's a really good information out there. Can you explain more about renderToNodeStream and how hydrating state works during streaming.

Collapse
 
marvelouswololo profile image
MarvelousWololo

Hello rahulAtGit,

I'm sorry I didn't see your message before. I'm don't know whether you are familiar with the concepts of Node.js streams. So I will share some links that will hopefully help you. But in summary this method returns a Node.js Readable Stream. This has performance gains over i.e. renderToString since it doesn't wait to parse your React nodes into a string, instead it will sending you data as it is parsing. If you don't have a huge component I would advise you to use renderToString instead since it is much simpler.

Regarding the state while streaming, let me know what's your specific question. Cheers.

reactjs.org/docs/react-dom-server....
nodejs.org/api/stream.html
github.com/substack/stream-handbook