
Summary
Key points of this document
- Where are the design challenges?
- How to define boundaries
- Details that matter in implementation
Overview
For small public sites, static generation without server-side processing reduces operational load. When combining React Router's SSG with Docker delivery, verifying the build artifacts is crucial. While SSG static sites appear simple to deliver, how build-time data, caching, 404s, redirects, and environmental differences are handled determines quality.
Where are the design challenges?
When delivering a React Router app as a static site, it might work on the development server but result in a 404 on direct access or reload after building. Incorrect cache settings can leave old HTML even after updates.
Static delivery does not allow per-request processing on the server. Parts requiring form submission, authentication, or dynamic data fetching must be separated into external APIs or other services. For public sites, SEO metadata should ideally be verified during the build.
React Router SSG can be treated as static files when published, making operations lighter. However, since data and environment variables fetched during the build are embedded into the HTML, update omissions can occur if you don't manage when and what was generated.
How to define boundaries
Define static generation targets per page, prioritize pre-generated HTML in Nginx, and use SPA fallback only when necessary. HTML gets a short cache, while hashed JS/CSS gets a long cache.
In design, clearly separate the build phase and the delivery phase. The Docker image should contain the generated build/client, and Nginx or lightweight servers should only handle static delivery. It's more stable not to include API calls or data generation during delivery.
Details that matter in implementation
In the Dockerfile, separate build and delivery stages, and copy only the generatedbuild/clientto Nginx. In Nginx configuration, explicitly definetry_files, compression, cache headers, and 404 pages.
The Dockerfile is divided into multi-stages for dependency installation, build, and delivery. Hashed assets are long-cached, HTML and sitemap are short-cached or no-cache, and the behavior of 404s and SPA fallback is also explicitly defined.
- Separate environment variables used during build from those exposed to the browser.
- In Nginx configuration, distinguish between fallback for non-existent static files and in-app routes.
- Include sitemap and robots in build artifacts; do not replace them after deployment.
Observe how it breaks
For verification, check the top page, sub-pages, non-existent URLs, reloads, OGP meta, and asset cache. It's crucial to launch the container and directly inspect build artifacts with curl or Playwright.
For verification, launch the Docker image locally and check representative pages, 404s, redirects, images, and OGP meta tags. It's important to view them via an actual delivery server, not by opening files directly.
Discarded options and trade-offs
SSG is fast and stable, but requires a build and delivery for every update. When dealing with frequently changing data, the decision is to combine static generation with API fetching or choose an SSR configuration.
While SSG is fast and has fewer points of failure, updates require a rebuild. It's not suitable for pages requiring high real-time interactivity or authentication. A decision must be made to separate the scope of static generation from the scope of client-side data fetching.
Decision criteria to retain in practice
React Router SSG is an option for lightweight operation of public sites. By clearly defining the scope of static generation, fallback, and caching, stable site operation can be achieved even with Docker delivery.
The advantage of static site operation is reducing processing during delivery. In return, by making build artifacts, caching, and fallback part of the design, the simplicity of SSG can be maintained.


