SPA / SSR / SSG の違い
Compare the three rendering strategies: SPA, SSR, and SSG. Understand when HTML is produced and how performance, SEO, and infrastructure requirements change.
Timeline: When is the HTML ready?
Three patterns side-by-side on a timeline. Columns flow from User → Server/CDN → Browser (1st paint) → JS Engine → Browser (2nd paint) → Interactive.
Where does the work happen?
Compute cost always lands somewhere: build time, server, or client. The three patterns differ mainly in where the cost falls.
Comparison Overview
| Aspect | SPA | SSR | SSG |
|---|---|---|---|
| When HTML is generated | Server only for shell / browser afterwards | Per-request on the server | At build time, for every page |
| Delivery | JS bundle + empty HTML shell | Dynamic HTML (rendered each time) | Static HTML files (CDN-ready) |
| Initial TTFB | Fast (shell only) but FCP is slow | Medium (depends on server work) | Very fast (served directly from CDN) |
| SEO | Weak if CSR-only; can be addressed by pairing with SSR/SSG | Strong (returns complete HTML) | Strong (returns complete HTML) |
| Content freshness | Always fresh via API | Fresh at request time | Fresh as of build (rebuild to update) |
| Server requirements | Static hosting + API server | Always-on app server (Node.js, etc.) | Static hosting only (S3 / CDN) |
| Representative frameworks | React, Vue, Angular, Svelte | Next.js, Nuxt, SvelteKit, Remix | Astro, Hugo, Jekyll, 11ty |
Which to choose
When SPA is a good fit
- Post-login dashboards / admin UIs (SEO not required)
- Complex forms and interactions as the core experience
- Backend is cleanly separated as an API
- Prioritize post-load interactivity over initial render
When SSR is a good fit
- Per-user content (carts, personalized recommendations)
- HTML must differ by login state
- Frequently updated content that also needs SEO (news, comments)
- Authentication / authorization must run server-side first
When SSG is a good fit
- Documentation sites, blogs, portfolios
- Marketing sites / landing pages
- Low update frequency (rebuilding is practical)
- Cost and performance top priority (CDN only)
Frequently Asked Questions
Common points of confusion when learning these three patterns, gathered in one place.
Q. Modern frameworks (Next.js / Astro / Nuxt) support all modes. How do I choose?
export const dynamic = ... / export const revalidate = .... 'Pick one mode for the whole site' is outdated thinking.Q. Is there a default answer to 'what should I start with'?
Q. Where does 'hydration' enter the picture — SPA, SSR, or SSG?
Q. Is ISR different from both SSG and SSR?
swr).Q. Is JAMstack just SSG?
Q. Which one has the best performance in the end?
In practice, these often mix
Modern meta-frameworks (Next.js, Astro, Nuxt, etc.) let you mix SPA / SSR / SSG per route within one project. Rather than labeling a whole site 'SSG', it's common to pick per page: 'article pages are SSG, the logged-in dashboard is SPA, the checkout confirm is SSR.'