🔥 All-Access Pass — $199 USD (Regular $499) · Unlock all 2,836 Astro themes ➔
komal.nakrani
Get All-Access Pass ($199)
ThemesCategoriesDocsBlogTips & TricksPricingGet All-Access Pass ($199)
Astro Fundamentals••By Komal Nakrani

MPA vs SPA: Why Astro Is a Multi-Page Framework

MPA vs SPA explained: how multi-page and single-page apps load, route and ship JavaScript, the real trade-offs, and why Astro chose MPA with optional client routing.

#Astro#MPA vs SPA#Architecture#Performance

MPA vs SPA comes down to where pages are built and how navigation works. A multi-page application (MPA) sends a complete HTML document from the server for every URL, and the browser loads a fresh page on each click. A single-page application (SPA) sends one HTML shell plus a JavaScript bundle, then renders every route in the browser and swaps views without a full page load. Astro is an MPA framework: every route is real HTML, and JavaScript is added only where a page needs it.

This explainer compares the two models, shows what each costs in practice, and explains how Astro gets SPA-like navigation without becoming an SPA.

Key Takeaways

  • An MPA returns finished HTML per URL; an SPA renders routes in the browser with JavaScript.
  • MPAs are faster on first load, easier for crawlers and AI tools to read, and need less JavaScript.
  • SPAs keep state across navigation and suit app-like interfaces with heavy interaction.
  • Astro is an MPA that adds interactivity through islands and optional client-side routing.
  • Most content sites (blogs, docs, marketing, e-commerce catalogs) fit the MPA model best.

How a multi-page application works

In an MPA, each URL maps to its own HTML document. When someone visits /pricing/, the server (or a CDN, for a static site) returns the full pricing page: header, content, footer, everything. When they click a link to /about/, the browser requests a new document and replaces the page.

That’s how the web worked before JavaScript frameworks, and it’s still how most of the web works. The advantages come from the browser doing what it was built to do:

  • Content arrives in the first response. The browser can paint text and images as soon as HTML streams in.
  • Navigation is native. Back and forward buttons, scroll restoration, link previews and “open in new tab” all work without code.
  • Every page is independent. A heavy script on one page doesn’t slow down others.
  • Crawlers see everything. Search engines and AI crawlers read the HTML directly, with no rendering step.

The cost is that each navigation reloads the page. Anything held in JavaScript memory (an open menu, audio playback, form input) is lost unless you persist it.

How a single-page application works

In an SPA, the server returns a minimal HTML shell, often little more than <div id="root">, plus a JavaScript bundle. The bundle starts a client-side router, fetches data, and renders the current route into the shell. Clicking a link doesn’t request a new document; the router intercepts the click, updates the URL with the History API, and renders the new view.

<!-- index.html in a typical SPA -->
<!doctype html>
<html lang="en">
  <head><title>App</title></head>
  <body>
    <div id="root"></div>
    <script type="module" src="/assets/index-3f9a.js"></script>
  </body>
</html>

That model has real strengths:

  • State survives navigation. A music player keeps playing; a sidebar stays open; data already fetched stays in memory.
  • Transitions can be instant once the bundle is loaded, because views render locally.
  • One architecture for rich, app-like interfaces such as dashboards, editors and chat tools.

The costs show up before that first interaction. The browser must download, parse and run the JavaScript before showing meaningful content. On a mid-range phone, that delay is often the largest part of load time, and it grows with every feature added to the bundle.

MPA vs SPA compared

Multi-page application Single-page application
First response Complete HTML for the page HTML shell plus JS bundle
First contentful paint Fast, as HTML streams After JS loads and renders
JavaScript required Only for interactive parts Entire app, including routing
Navigation New document per URL Client-side router swaps views
State across pages Lost unless persisted Kept in memory
SEO and AI crawlers HTML readable immediately Depends on rendering or SSR
Back button, deep links Native Must be handled by the router
Failure mode Missing JS means missing widgets Missing JS can mean a blank page
Best for Content sites, marketing, docs, stores Dashboards, editors, real-time apps

Modern SPA frameworks add server-side rendering to close the first-load gap, so the server sends HTML and the client “hydrates” it. That helps, but the full application JavaScript still ships and runs, because the client router needs the whole component tree to take over.

Why Astro chose the MPA model

Astro is built for content-driven websites. For those sites, the first page view matters most: a visitor arrives from search, reads, maybe clicks once or twice, and leaves. Optimizing for that visit means sending HTML quickly and keeping JavaScript small.

So Astro renders every route to HTML, at build time for static pages or per request with an adapter. The output for a page is the page, not an app shell. Components written in Astro produce no client JavaScript at all, which is why Astro is described as zero JavaScript by default.

Interactivity is added per component through islands. A search box, a carousel or a cart button can be a React, Svelte or Vue component hydrated with a client:* directive, while the rest of the page stays static HTML:

---
// src/pages/index.astro
import Hero from '../components/Hero.astro';
import Newsletter from '../components/Newsletter.jsx';
---
<Hero />
<Newsletter client:visible />

Only Newsletter and its framework runtime ship to the browser, and only when it scrolls into view. The islands architecture guide explains the model in depth, and the client directive guide helps you pick the right directive.

SPA-like navigation in an Astro MPA

The main thing people miss in MPAs is smooth navigation. Astro covers that in two ways without turning the site into an SPA.

Native view transitions. Modern browsers support cross-document view transitions in CSS. Add one rule and navigations between same-origin pages animate, with no JavaScript:

/* src/styles/global.css */
@view-transition {
  navigation: auto;
}

Browsers that don’t support it simply load the page normally.

Astro’s <ClientRouter />. For more control, add the client router to your layout’s <head>. It intercepts link clicks, fetches the next page’s HTML, and swaps the document with animated transitions. Elements marked transition:persist survive navigation, which keeps a video or audio player running across pages.

---
// src/layouts/BaseLayout.astro
import { ClientRouter } from 'astro:transitions';
---
<html lang="en">
  <head>
    <ClientRouter />
  </head>
  <body>
    <slot />
  </body>
</html>

The important difference from an SPA router: every route still exists as real HTML on the server. The client router fetches that HTML instead of rendering views from a JavaScript bundle, so crawlers, deep links and no-JS visitors all get full pages. Prefetching (prefetch: true in config) makes those fetches start on hover, so navigation feels instant; see the prefetch tip.

When an SPA is the better choice

An MPA isn’t always right. Choose an SPA (or an SPA-leaning framework) when:

  • The product is an application people work in for long sessions: an editor, a dashboard, a design tool.
  • Most screens sit behind a login, so search visibility doesn’t matter.
  • State must persist across many views, and reloading would be disruptive.
  • Interaction is the main content, not reading.

Many products mix both: an Astro MPA for the marketing site, docs and blog, and a separate SPA for the logged-in app at app.example.com. You can also mount a full SPA inside a single Astro route as one large island with client:only, which keeps the rest of the site static. The when not to use Astro article covers the edge cases.

What the MPA model means for SEO and AI answers

Search engines can render JavaScript, but rendering is deferred and costly, and many AI crawlers fetch HTML without executing scripts at all. An MPA gives them the content in the first response. Titles, headings, structured data and internal links are all present before any script runs.

That’s a practical advantage for a content site trying to rank and be cited. The Astro SEO guide covers the rest of the checklist, from canonical URLs to JSON-LD.

How to tell which model a site uses

Open a page, view the source (not the inspector), and look:

  1. If the source contains the article text, headings and links, it’s server-rendered HTML, typical of an MPA.
  2. If it’s mostly an empty <div> and script tags, it’s a client-rendered SPA.
  3. Click a link with the network panel open. A new document request means MPA navigation. Only fetch or xhr requests mean client-side routing.

Every Komal theme is an Astro MPA: each page is static HTML with JavaScript only for components that need it. You can check this yourself on any Astro theme live preview with the steps above. The official Astro docs on MPAs vs SPAs give Astro’s own take.

FAQ

What is the difference between an MPA and an SPA?

An MPA returns a complete HTML document for each URL and loads a new page on navigation. An SPA loads one HTML shell and a JavaScript bundle, then renders every route in the browser and swaps views without full page loads.

Is Astro an SPA or an MPA?

Astro is an MPA framework. Each route is rendered to its own HTML page. You can add client-side navigation with <ClientRouter /> or native view transitions, but pages remain real HTML documents.

Are MPAs better for SEO than SPAs?

Generally yes, because content is in the HTML of the first response, so crawlers can read it without running JavaScript. SPAs with server-side rendering can be indexed well too, but they add complexity and ship more JavaScript.

Can an MPA feel as fast as an SPA?

Yes, for most content sites. Static HTML served from a CDN, prefetching on hover, and view transitions make navigation feel immediate, while the first page load is usually faster than an SPA’s.

Can I use React in an Astro MPA?

Yes. Add the React integration and use React components as islands with a client:* directive. Each island hydrates independently, so React only loads for the parts of a page that need it.