Skip to the workspace
Pebellslearn by building
How a Full-Stack App Fits Together  ›  Capstone Project

Pages or Data: Who Builds the HTML?

JavaScript 14 minA server can answer with a finished HTML page or with JSON that JavaScript turns into a page in the browser, and the right choice depends on whether a page serves searchable public visitors or logged-in interactive users.

full stack / Pages or Data: Who Builds the HTML?

Explore each scene at your own pace.

01 · The rule

The rule

Pages or Data: Who Builds the HTML?

Two web apps can look identical and still split the work in opposite ways. In one, the server sends finished HTML and the browser simply shows it. In the other, the server sends raw data and JavaScript in the browser builds the page. Sprout could be built either way, so it is worth knowing what each choice buys.

The rule

Either the server sends a finished page, or it sends data and the browser builds it.

Server-rendered. A request for /plants runs a query on the server, pours the rows into an HTML template and returns a complete page with Content-Type: text/html:

<ul>
  <li>Fern, water every 3 days</li>
  <li>Cactus, water every 21 days</li>
</ul>

Every click that moves to another page asks the server for another finished page.

Client-rendered. The first response is a small HTML shell plus a JavaScript bundle. Once loaded, the JavaScript calls an API such as /api/plants and receives only data:

[{"id": 7, "name": "Fern", "water_every_days": 3},
 {"id": 9, "name": "Cactus", "water_every_days": 21}]

The browser turns that JSON into the list itself. From then on, only data travels.

Server sends HTML Server sends JSON
First view content arrives in the first response waits for the script, then the data
Search engines see the content directly may see an empty shell
After loading a new page per navigation small data requests; feels like an app
A future phone app needs a separate API reuses the same API

Many modern frameworks mix the two: they render the first view on the server, then let JavaScript take over in the browser. The question "who builds this HTML?" still decides where each piece of code runs.

This course builds Sprout's logged-in screens as a React client over a JSON API. Those screens sit behind a login, so search engines never see them anyway, and the same API can later serve a phone app.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.