question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Simple server rendering

See original GitHub issue

There 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:closed
  • Created 7 years ago
  • Reactions:14
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

6reactions
andrezzoidcommented, Dec 28, 2016

Would love to see this in the next CRA version 👍

1reaction
viankakrisnacommented, Nov 27, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found