liveBook · Manning

Server-side rendering

As explained in Secrets of the JavaScript Ninja, Third Edition

A rendering technique in which HTML for a web page is generated on the server before being delivered to the browser.

Server-side rendering (SSR) generates a page’s HTML on the server and sends it to the browser before sending the JavaScript. The browser can receive page content before running that JavaScript. section 1.2.1 section 4.4

SSR addresses a common tradeoff in rich web applications: sites that send a blank page plus JavaScript leave users waiting for the code to download and execute before content appears. The same rendering code must run on both the server and browser, which can make SSR challenging to implement. section 1.2.1

Some full-stack React frameworks provide SSR by default and split JavaScript into chunks for the pages that need them:

SSR can improve initial page delivery, but it is not a one-sided rendering change: the rendering code must remain usable in both environments. Frameworks designed for that shared setup can help meet the challenge. section 1.2.1 section 4.4

How Secrets of the JavaScript Ninja, Third Edition covers it

How deep it goes
Explains the rendering flow and shared-code constraint, while deferring implementation to frameworks.
Examples
Names Next.js, Remix, and Astro as React frameworks that render on the server by default and split page-specific JavaScript.
What you can do after
Understand how SSR changes initial page delivery and why its code must run in both server and browser environments.
How it connects
Connects SSR to JavaScript, React, web UI frameworks, and JavaScript code splitting.

Also explained in

Compare how 13 books explain server-side rendering →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secrets of the JavaScript Ninja, Third Edition. The section links point to the parts of the book it draws on.