If I want to serve web page that shows table of some contents, I have two option.
- When client request page, Node server just response with JSON data and script for draw HTML table. And draw table in client side with Javascript.
- When client request page, Node server render all of HTML code for table and response the code to client. So client will receive full HTML.
Which one is better way to render page? I have not enough skills about front-end so confuse what to do.
you can use reactjs in nodejs server exemple link:
https://medium.com/jspoint/a-beginners-guide-to-react-server-side-rendering-ssr-bf3853841d55
other link for render react app in server nodejs
https://www.freecodecamp.org/news/server-side-rendering-your-react-app-in-three-simple-steps-7a82b95db82e/
I think the node server should render the HTML in case you need to add more content to the HTML. You might not be doing this, and I don’t want to assume you are, but if you are sending the code as a string and using eval() on it, I don’t recommend it. For more information, visit eval() is evil. You also can send a function to the client’s javascript, but, you could have to add more code later on, and also, malicious code could get hacked into the function resulting in high damage to your node server. It isn’t likely, but I think you should use your second option.