Single-Page Application (SPA)

A Single-Page Application (SPA) is a web application that loads a single HTML document on first visit and thereafter updates the UI dynamically via JavaScript — without triggering full page reloads from the server. Navigation between “pages” is handled client-side by a router (e.g. react-router) that intercepts URL changes and swaps out view components.


How It Works in the burgerApp

The Burger Builder is a classic SPA:

  1. public/index.html — a single HTML shell with <div id="root">.
  2. src/index.js — mounts the react component tree into #root.
  3. BrowserRouter intercepts all navigation events; Switch/Route decides which container to render.
  4. No page reload occurs when navigating //checkout/orders.

Trade-offs

BenefitCost
Fast subsequent navigation (no full reload)Larger initial JavaScript bundle
Rich interactivity, app-like feelRequires client-side routing complexity
Backend can be a pure APISEO requires extra work (SSR or pre-rendering)
Easier to manage global state (e.g. redux)Initial page may be slow on slow networks

See Also