K
K
KirylLapouski2018-02-09 21:57:54
JavaScript
KirylLapouski, 2018-02-09 21:57:54

Is it possible to work with the DOM on the server side?

Hello, how to insert an element into the DOM tree of an html file that is located on the server?
There is a server (node ​​js express) that returns an html page. Based on the request parameters from the client, we need to render the react component, and insert it into the html document, and then send this document to the user.
How to do it?
Another question: is it normal practice in a component that is rendered on the client to send a request to the server when rendering to get the data that needs to be displayed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2018-02-09
@KirylLapouski

Yes, it is normal. Moreover, rendering and api can be on different servers. A request from a server to another server or to itself must be the same as from a client, with the same headers.
See existing react ssr examples.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question