Learning paths / Application foundations / Frontend, backend and the browser

Static sites, server-rendered apps and APIs

Reading · 6 min · Module 1, lesson 2 of 417 min left in this module

Module 1 · Frontend, backend and the browserLesson 2 of 4

Goal: Pick the right shape for a web project, from a static site, a server-rendered app, or a single-page app with an API.

Key idea

Web projects come in three shapes, set by what the server does for each request: hand over a file that already exists (a static site), build the page (a server-rendered app), or answer with data the browser turns into a page (a single-page app and an API). Choose by whether pages change per visitor and how much happens on screen.

Static site

Every page is a file made before anyone visits: HTML, CSS, JavaScript and images. A build step can produce them from templates or Markdown, with tools such as Hugo, Astro or vite build. After that, the server's only job is handing files over, so it's fast and there's little to break.

It fits documentation, landing pages, blogs and portfolios. On its own it can't show data that's different for each visitor or save what they type.

Server-rendered app

The server builds the HTML for each request: it reads the database, fills in a template and sends a finished page. Rails, Django, Laravel and Express with templates all work this way.

It fits sites where pages depend on who's signed in or on changing data, like a store or a forum. The cost is a server running all the time, and every new page is a trip to it.

Single-page app and an API

The browser downloads one app, built with a framework such as React, Vue or Svelte, and draws every page itself. For data, it calls an API: a backend that answers with data, usually JSON, instead of pages. The next module is about APIs.

It fits app-like screens with a lot happening on them: dashboards, editors, chat. The same API can serve a mobile app too. The costs: two parts to build and deploy, and a slower first load, because the browser runs the app before it shows anything.

The app itself is only files once built, like a static site. The API is the part that needs a server.

Choosing

ShapePer request, the serverPages differ per visitorGood for
Static siteHands over a fileNoDocs, landing pages, blogs
Server-rendered appBuilds the pageYesStores, forums, account pages
Single-page app and APIAnswers with dataYes, drawn in the browserDashboards, editors, apps with a mobile client

Start with the simplest shape that fits. Many products use two: a static marketing site, and an app behind the sign-in.

Frameworks that do all three

Next.js, Nuxt and SvelteKit can make one page static, render another on the server and run a third in the browser, all in one project. The shapes still apply page by page. When you deploy, the project as a whole needs a server if any page is rendered on request.

Check yourself

A band wants a site with its tour dates and photos, updated a few times a year. Which shape?
In a single-page app, what does the API send back?

In the docs