React SSG renders HTML at build time and writes static files suitable for any static host. mode="ssg" emits non-hydrated HTML, while mode="hybrid" hydrates only when interactivity is required.
1graph TD
2 Build[Vite Build] --> SSR[SSR Bundle]
3 SSR --> Pre[Prerender Step]
4 Pre --> HTML[Static HTML Files]SSG as a Mode
SSG is a policy-controlled mode of the React target. It keeps the DSL unified and avoids separate react-ssg or react-ssr targets.
Policy Configuration
1rendering: {
2 mode: "ssg",
3 prerender: {
4 routes: "auto",
5 emitSitemap: true,
6 emitRobotsTxt: true
7 }
8}Rendering Mode Resolution
Lowering determines the prerender flow, route discovery strategy, and the metadata to inject. Emitters should not guess.
Route Discovery
Static routes are prerendered. Dynamic routes are skipped with warnings unless explicitly provided.
Prerender Pipeline
Build produces assets and manifest. SSR bundle renders each route. The prerender step writes static HTML and injects asset links.
Output Contract
HTML files are written to the root outDir with folder-style routing. The SPA fallback is preserved as index.spa.html.
Metadata Injection
Metadata is resolved during lowering from page definitions and policy. Emitters inject final values into static HTML.
Asset Management
Asset hashing and manifest-based injection provide stable caching. Static HTML links to the correct CSS and JS bundles.
Deployment
React SSG output is pure static files. It works on GitHub Pages, Netlify, and any static host without server runtimes.
Why Avoid SSR Runtime
SSR runtime introduces server dependencies and non-determinism. irgen favors build-time rendering for predictable artifacts.