# Single-Page Application \(SPA\)

A single-page application loads a document shell and handles later views and navigation mainly through client-side JavaScript.

- Type: framework
- Domain: Engineering & architecture
- Level: Intermediate
- Last reviewed: 2026-09-23
- Original: [Soroush’s Product Wiki](<https://wiki.soroush.uk/topic/single-page-application/>)

## What it means

A single-page application \(SPA\) is a web delivery architecture in which the browser usually keeps one document loaded while JavaScript changes views, fetches data, and updates the URL and history. It describes navigation and rendering responsibility, not whether the product literally has one screen or whether its first response contains useful HTML.

## Why it matters

SPAs can support fluid, stateful interactions, but they move routing, rendering, error handling, accessibility, and more recovery work into the browser. The choice affects startup cost, resilience, caching, analytics, and search discovery.

## When to use it

Consider an SPA for highly interactive products where state persists across many in-product transitions and the team can own client performance and accessibility. Prefer conventional document navigation or a hybrid when pages are mostly content, work with little JavaScript, or need simple operational behavior.

## How it works

1. A server returns an application document with markup, styles, and script references.
2. Client code initializes state and renders or activates the current view.
3. A router maps URLs to views and updates browser history without full document loads.
4. The application fetches data and incrementally updates the DOM as users act.
5. The team restores focus, announcements, scroll, errors, and deep-link behavior for each transition.

## A practical example

A collaborative planning tool keeps filters, draft edits, and live presence active while users move among boards. The team chooses an SPA but code-splits routes and explicitly manages page titles, focus, history, and failed data requests.

## Where it breaks

An SPA can ship substantial JavaScript, delay interactivity, fail poorly on weak devices, and recreate browser navigation behavior. It is not inherently faster than a multi-page application, and server rendering does not remove its client runtime costs.

## Common mistakes

- Choosing an SPA because it is fashionable rather than because interactions require persistent client state.
- Breaking deep links, back and forward navigation, or scroll restoration.
- Changing views without updating titles, focus, and assistive-technology announcements.
- Treating a quick development server as evidence of production performance.

## Visualization

[View the visualization on the website](<https://wiki.soroush.uk/topic/single-page-application/#visualization-single-page-application>)

## Sources

1. [Rendering on the Web](<https://web.dev/articles/rendering-on-the-web>) — web.dev · Official technical guidance
2. [History API](<https://developer.mozilla.org/en-US/docs/Web/API/History_API>) — MDN Web Docs · Official technical documentation

## Related topics

- [Multi-Page Application \(MPA\)](<https://wiki.soroush.uk/topic/multi-page-application/>)
- [Client-Side Rendering \(CSR\)](<https://wiki.soroush.uk/topic/client-side-rendering/>)
- [Client-Side Routing](<https://wiki.soroush.uk/topic/client-side-routing/>)
