Simple server rendering
See original GitHub issueThere have been some people asking for server rendering with node.js, but what if instead we did server rendering agnostic of the backend?
The idea is to create a UMD build which exports one function. The function takes some arguments and returns a renderToString result. The generated version of this entry point would be very simple, but it could be extended by the user to support react-router, redux, etc. They can add these things without ejecting, which is nice.
module.exports = (options) => ReactDOMServer.renderToString(<App data={options.data} />);
This bundle could be used in node.js with a simple require()
, or loaded into phpv8 or similar and expose a global.
Building this bundle would be a separate build task with an optional watch mode. For node users, nodemon would pick up the bundle change and restart the server.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:14
- Comments:14 (11 by maintainers)
Top Results From Across the Web
How to implement server-side rendering in your React app in ...
In this tutorial, we'll use server-side rendering to deliver an HTML response when a user or crawler hits a page URL.
Read more >How to Enable Server-Side Rendering for a React App
Server -side rendering (SSR) is a popular technique for rendering a client-side single page application (SPA) on the server and then sending a ......
Read more >Basics of React server-side rendering with Express.js
Server -side rendering is a useful technique you can use when you want to improve the load times and SEO of your React...
Read more >A beginner's guide to React Server-Side Rendering (SSR)
In this lesson, we are going to talk about server-side rendering (SSR), its benefits, and its pitfalls. Then we will set up a...
Read more >Rendering on the Web
Server rendering generates the full HTML for a page on the server in response to navigation. This avoids additional round-trips for data ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Would love to see this in the next CRA version 👍
this could be useful! I have already experimented with server rendering with create react app, but it’s a little pain to setup. I end up wrapping each css imports with a helper function, and just included the generated css from the build script. (also need to be careful with browser globals). It would be handy if instead we have something like what @brigand said.