We use cookies to enhance your experience on the site
CodeWorlds

SSR Concepts: SPA vs SSR vs SSG vs ISR

The NOVA LAB Command Center must deliver information as quickly as possible. Different rendering strategies are like different communication systems on the station β€” each has its advantages depending on the situation.

SPA β€” Single Page Application

A traditional Vue application is an SPA (Single Page Application):

  1. The browser downloads an empty HTML file
  2. It loads the JavaScript (Vue bundle)
  3. JavaScript renders the entire page in the browser
  4. Navigation happens without page reloads
1Server β†’ [empty HTML + JS bundle] β†’ Browser β†’ [rendering]

SPA Advantages:

  • Smooth navigation without reloads
  • Rich interactivity
  • Simple hosting (static files)

SPA Disadvantages:

  • Slow initial load (large JS bundle)
  • Empty page until JS loads
  • Poor SEO β€” bots see empty HTML

SSR β€” Server-Side Rendering

SSR renders the page on the server and sends ready HTML:

  1. The server receives a request
  2. Vue renders the component on the server to HTML
  3. It sends the ready HTML to the browser
  4. The browser displays the page immediately
  5. JavaScript is loaded and "hydrates" the page (adds interactivity)
1Request β†’ Server [renders HTML] β†’ Browser [displays + hydration]

SSR Advantages:

  • Faster First Contentful Paint (FCP)
  • Excellent SEO β€” bots see full HTML
  • Better performance on slow devices

SSR Disadvantages:

  • Higher server load
  • Longer Time to Interactive (TTI)
  • More complex infrastructure

SSG β€” Static Site Generation

SSG generates HTML at build time:

  1. During
    npm run build
    β€” each page is prerendered to HTML
  2. HTML files are ready to be served
  3. No server needed β€” plain static hosting
  4. JavaScript hydrates the page on the client
1Build time β†’ [generates HTML] β†’ Deploy β†’ CDN β†’ Browser

SSG Advantages:

  • Fastest possible response (files from CDN)
  • No server β€” cheapest option
  • Excellent SEO

SSG Disadvantages:

  • Content doesn't change between builds
  • Every change requires a rebuild
  • Not suitable for dynamic data

ISR β€” Incremental Static Regeneration

ISR combines SSG and SSR β€” pages are generated statically but can refresh:

  1. First visit β€” page served from static cache
  2. After a set time β€” the page is regenerated in the background
  3. Next visit gets the updated version
1Request β†’ [cache/CDN] β†’ if stale β†’ regenerate in background β†’ new version

ISR Advantages:

  • SSG speed + SSR freshness
  • Automatic refreshing

ISR Disadvantages:

  • More complex configuration
  • Data may be momentarily outdated (stale-while-revalidate)

Hydration β€” the Key to Interactivity

Hydration is the process where Vue "takes over" the static HTML generated by the server and adds interactivity to it:

1Server: <button>Click</button>  ← static HTML
2   ↓ hydration
3Client: <button @click="handler">Click</button>  ← interactive

Vue compares the virtual DOM with the existing HTML and attaches event handlers, refs, and reactivity β€” without re-rendering the entire DOM.

When to Use Which Strategy?

| Strategy | Use when... | |----------|-------------| | SPA | The app requires rich interactivity (dashboard, editor) | | SSR | SEO matters + dynamic data (store, blog with comments) | | SSG | Content changes rarely (documentation, landing page) | | ISR | Content changes, but not in real time (blog, catalog) |

Go to CodeWorlds→