Changing the title tag
You can find the source HTML file in the
public folder of the generated project. You may edit the
<title> tag in it to change the title from “React SSR App” to anything else.
Note that normally you wouldn’t edit files in the
public folder very often. For example, adding a stylesheet is done without touching the HTML.
If you need to dynamically update the page title based on the content, you can use the browser
document.title API. For more complex scenarios when you want to change the title from React components, you can use React Helmet, a third party library. For more information on adding React Helmet to your project follow advice in this section.
Sending Data from the Server to the Client
Similarly to how html content is passed from the server to the client via
__HTML_CONTENT__ placeholder, you can add a placeholder in the HTML that injects global variables, for example:
Then, on the server, you can replace
__SERVER_DATA__ with a JSON of real data right before sending the response. The client code can then read
window.SERVER_DATA to use it. Make sure to sanitize the JSON before sending it to the client as it makes your app vulnerable to XSS attacks.
This is useful if using Redux to pass the store created on the server back to the client as the initial state. For more information on adding Redux and passing the store back to the client follow advice in this section.