docs/oss/core-concepts/react-server-rendering.md
See also Client vs. Server Rendering.
See the example Webpack setup here: github.com/shakacode/react_on_rails_demo_ssr_hmr.
Here's a decent article to introduce you to server rendering. Note, React on Rails takes care of calling the methods in ReactDOMServer.
During the Rails rendering of HTML per a browser request, the Rails server will execute some JavaScript to create a string of HTML used for React server rendering. This resulting HTML is placed with in your Rails view's output.
The default JavaScript interpreter is ExecJS. If you want to maximize the performance of your server rendering, then you want to use React on Rails Pro which uses NodeJS to do the server rendering. See the docs for React on Rails Pro.
See this note.
react_component view helper method provides the prerender: option to switch on or off server rendering.config.server_bundle_js_file = "server-bundle.js" in your config/initializers/react_on_rails.rbServer rendering is used for either SEO or performance reasons.
window. Animations, globals on window, etc. just don't make sense when you're trying to run some JavaScript code to output a string of HTML.setTimeout, setInterval, and clearInterval similarly don't make sense when server rendering.For a comprehensive list of ExecJS constraints, see ExecJS Limitations.
:::tip Pro Upgrade
React on Rails Pro includes a dedicated Node.js renderer that eliminates ExecJS limitations and improves SSR performance by 3-10x. It also supports streaming SSR with React 18/19's renderToPipeableStream for faster Time to First Byte. Learn more →
:::