SPA vs SSR vs SSG: Rendering Strategies Explained
Understand Single Page Apps, Server-Side Rendering, and Static Site Generation — how each works, performance tradeoffs, SEO impact, and when to use which.
What you'll learn
- ✓How SPAs, SSR, and SSG render pages differently
- ✓Performance and SEO implications of each approach
- ✓When to use each rendering strategy
- ✓How ISR and streaming fit into the picture
- ✓Mixing strategies in modern frameworks
Prerequisites
- •Basic HTML and JavaScript understanding
Every web page reaches the browser as HTML. The question is when and where that HTML gets generated. The answer determines your site’s performance, SEO, and architecture.
Single Page Application (SPA)
An SPA sends a minimal HTML shell and a large JavaScript bundle to the browser. JavaScript renders everything client-side.
<!-- What the server sends -->
<html>
<body>
<div id="root"></div>
<script src="/app.js"></script>
</body>
</html>
The browser downloads app.js, executes it, fetches data from APIs, and renders the UI. Subsequent navigation happens entirely in the browser — no full page reloads.
How it works
- Browser requests the page
- Server returns empty HTML shell + JavaScript bundle
- Browser downloads and executes JavaScript
- JavaScript makes API calls and renders content
- User sees the page
Pros
- Smooth, app-like navigation after initial load
- Clear separation between frontend and backend
- Works well for highly interactive applications
- Simple deployment — just static files behind a CDN
Cons
- Slow initial load — nothing renders until JavaScript executes
- Poor SEO — search engines may not execute JavaScript
- Blank screen while JavaScript loads (poor perceived performance)
- Requires JavaScript — no progressive enhancement
Server-Side Rendering (SSR)
SSR generates the full HTML on the server for every request. The browser receives a complete page immediately.
User Request → Server renders HTML → Browser displays page → JavaScript hydrates
How it works
- Browser requests the page
- Server fetches data and renders HTML
- Browser receives and displays complete HTML
- JavaScript bundle loads and “hydrates” the page (attaching event handlers)
- Page becomes interactive
Pros
- Fast First Contentful Paint — the browser has real HTML immediately
- SEO-friendly — crawlers see complete content without executing JavaScript
- Dynamic content — HTML is generated per-request with fresh data
- Works without JavaScript (content is visible even if JS fails)
Cons
- Slower Time to First Byte — the server must render before responding
- Server load — every request requires rendering work
- Hydration cost — JavaScript still loads and attaches to the server-rendered HTML
- More complex infrastructure than static files
Static Site Generation (SSG)
SSG generates all HTML at build time. Pages are pre-built and served as static files from a CDN.
Build time: Fetch data → Generate HTML files → Deploy to CDN
Request time: CDN serves pre-built HTML → Browser displays instantly
How it works
- At build time, the framework generates an HTML file for every page
- HTML files are deployed to a CDN
- When a user requests a page, the CDN serves the pre-built file
- No server-side rendering happens at request time
Pros
- Fastest possible response — CDN serves a static file
- No server required — just static file hosting
- Highly cacheable — the same file serves every user
- Maximum SEO — complete HTML available instantly
- Cheap to host and scale
Cons
- Build time grows with page count — thousands of pages take minutes
- Content is stale until the next build
- Not suitable for per-user or real-time content
- Rebuild required for any content change
Incremental Static Regeneration (ISR)
ISR bridges SSG and SSR. Pages are statically generated but can be re-generated in the background after a time interval:
First request: Serve cached static page
Background: Re-generate the page with fresh data
Next request: Serve the updated page
ISR gives you the performance of static pages with near-real-time content freshness. Next.js popularized this pattern.
Streaming SSR
Traditional SSR waits for all data before sending any HTML. Streaming SSR sends HTML in chunks as data becomes available:
Server starts sending <html><head>... immediately
Shell renders while data loads
Data arrives → server streams the content chunk
Browser progressively displays content
This dramatically improves Time to First Byte because the browser starts rendering before the server finishes processing.
Comparison Table
| Factor | SPA | SSR | SSG |
|---|---|---|---|
| First Contentful Paint | Slow | Fast | Fastest |
| Time to Interactive | Slow | Medium | Fast |
| SEO | Poor | Excellent | Excellent |
| Content freshness | Real-time | Real-time | Build-time |
| Server required | No (API only) | Yes | No |
| Hosting cost | Low | Medium-High | Lowest |
| Build time | Fast | N/A | Grows with pages |
| Personalization | Easy | Easy | Hard |
When to Use SPA
- Internal tools and dashboards behind authentication
- Highly interactive applications (design tools, IDEs, email clients)
- When SEO does not matter
- When you want a clear frontend/backend API boundary
When to Use SSR
- E-commerce with dynamic pricing and inventory
- Social media feeds with personalized content
- Any page that needs SEO and real-time data
- Content that changes frequently and varies per user
When to Use SSG
- Blogs, documentation, and marketing sites
- Content that changes infrequently (daily or weekly)
- Landing pages and portfolio sites
- Any site where build-time content is acceptable
Mixing Strategies
Modern frameworks let you mix strategies per page. In Next.js, your marketing pages can be SSG, your product pages can use ISR, and your dashboard can be SSR or client-rendered. This is the practical reality — few applications use just one strategy.
/ → SSG (marketing page)
/blog/* → SSG (content pages)
/products/* → ISR (refreshed every hour)
/dashboard → SSR (per-user data)
/settings → SPA (client-side only)
Wrapping Up
SPA, SSR, and SSG are not competing philosophies — they are tools for different problems. Use SSG for content, SSR for dynamic pages that need SEO, and SPA patterns for interactive features. Modern meta-frameworks let you mix all three in one application, so choose per-page based on the content and user experience requirements.
Related articles
- Next.js Next.js ISR vs SSR vs SSG
A clear comparison of static, server-rendered, and incrementally regenerated pages in Next.js, with rules for choosing the right strategy.
- Web Core Web Vitals Optimization Techniques
Hands-on techniques to improve LCP, INP, and CLS scores: image optimization, script deferral, layout stability patterns, and interaction responsiveness strategies.
- Web Web Performance: Core Web Vitals Guide
A practical guide to Core Web Vitals: LCP, INP, and CLS. How they are measured, what hurts them, and concrete fixes that move the numbers.
- Astro Astro Islands Architecture Explained
Learn how Astro ships zero JavaScript by default and only hydrates the interactive components you mark as islands.