
Summary
Key points of this document
- Where are the design challenges?
- How to define boundaries
- Details that matter in implementation
Overview
React Router SSR excels in initial rendering and metadata control. However, it requires more consideration for the execution environment, monitoring, and caching than static delivery. When running React Router SSR on Cloud Run, you need to consider not only rendering speed but also cold starts, caching, health checks, and logs as a whole.
Where are the design challenges?
When deploying an SSR app to Cloud Run, container startup, Node processes, external API calls, and rendering errors directly impact the user's display. Operating it with the mindset of a static site makes troubleshooting difficult during failures.
Cloud Run scales based on requests, so you need to consider cold starts and concurrency. If SSR calls external APIs, API latency will slow down the entire HTML response.
SSR has advantages in initial display and meta tag control, but since it involves server execution, the scope of operations increases. In Cloud Run, cold starts, concurrency, timeouts, and health checks directly impact user experience.
How to define boundaries
We confirm the necessity of SSR on a per-page basis. Pages that don't require authentication or dynamic metadata are leaned towards static generation, while SSR pages are designed with data fetching timeouts, error displays, and caching.
In the design, we separate data fetching required for SSR, static asset delivery, API calls, and authentication. Cloud Run containers are kept stateless, and per-request state is stored in cookies, external databases, or external caches.
Details that matter in implementation
In Docker, include only the artifacts necessary for Node execution and provide a lightweight endpoint for health checks. Adjust Cloud Run's concurrency, minimum instances, and memory based on actual measurements. Logs should record URL, status, and rendering time.
In the Dockerfile, clearly separate the Node.js server and build artifacts, and provide a health endpoint. Logs should include request ID, route, rendering time, and data fetching time to identify slow pages.
- Separate environment variables and public config to avoid embedding sensitive information into HTML with SSR.
- Decide whether static assets are served via Cloud Run or CDN, and separate cache headers accordingly.
- For pages where cold starts are an issue, consider minimum instances or optimization for lightness.
Observe how it breaks
During verification, check direct access, reloads, external API delays, SSR exceptions, cold starts, and the mix of old and new revisions immediately after deployment. It's also reassuring to check HTML metadata of key pages with Playwright.
During verification, check initial access, continuous access, deep URLs, 404s, authentication pages, and API delays. Beyond Lighthouse, examine rendering times in Cloud Run logs to pinpoint bottlenecks.
Discarded options and tradeoffs
SSR is flexible, but it increases the scope of operations compared to static delivery. Pages without clear reasons like SEO or initial display before authentication are better kept lighter by leaning towards SSG or SPA.
While SSR is strong for SEO and initial display, it increases operational complexity. If not all pages require SSR, combining it with static generation or client-side fetching is more rational.
Decision criteria to leave for the team
If you use React Router SSR with Cloud Run, you must treat rendering as a critical server process for your application. It's important to confirm the value of SSR for each page and design monitoring and caching accordingly.
If you operate React Router SSR on Cloud Run, you need to design it not just as a frontend implementation but as a server operation. Making rendering times visible in logs provides clues for improvement.


