SPA vs MPA
Comparing Single-Page Applications (client-side routing inside one HTML shell) against Multi-Page Applications (full server HTML navigations)
Table of Contents
Structure Diagram
Client routing · App-like UX
- NavigationNo full reload; fetch JSON only
- Initial LoadHeavier initial JS bundle
- StatePersistent client state across routes
- Best FitSaaS apps, editors, dashboards
Server documents · Simple & SEO-native
- NavigationFull HTML document per URL
- Initial LoadLean per-page payload
- StateManaged via server session/URL
- Best FitContent sites, docs, catalogs
What is SPA vs MPA?
Comparing Single-Page Applications (client-side routing inside one HTML shell) against Multi-Page Applications (full server HTML navigations). It is a core concept in Rendering & Frontend within Web Dev.
Core Principles
A Single-Page Application (SPA) loads a single HTML shell and intercepts navigation on the client via the History API, fetching JSON data and swapping views without full browser reloads. A Multi-Page Application (MPA) requests a fresh HTML document from the server on every route change.
Modern meta-frameworks (Next.js, Remix, SvelteKit) blend both worlds: delivering an MPA-style server-rendered HTML response on initial entry, then upgrading subsequent navigations to SPA-style client transitions.
Practical Takeaways
- Choose based on product workload: Rich interactive tools behind authentication (editors, dashboards, chat) shine as SPAs; search-driven content, docs, and large catalogs benefit from MPA or SSR/SSG hybrids.
- Guard against SPA bloat: Because SPAs never hard-reload, enforce route-level code splitting and clean up timers/subscriptions to avoid memory leaks.
- Enhance MPAs with modern browser APIs: Combining prefetching with the View Transitions API gives MPAs near-SPA smoothness with a fraction of the JavaScript complexity.
Notable Examples
- SPAs: Gmail, Figma, and Linear—where persistent client state and instant in-app interactions are paramount.
- MPAs: Wikipedia, Amazon, and Astro-powered content sites—where lean payloads and search discoverability dominate.