Server-Side Rendering
Server-side rendering (SSR) - is default tramvai
rendering mode, which means that for every user request framework will generate HTML page in runtime, and this page content may be completely dynamic and all data will be fresh.
Also it means that all tramvai
application code needs to be universal (or isomorphic) - ready to run both on the server and the client.
You can find complete request lifecycle at Application Lifecycle documentation, and how routing works in Navigation Flow page.
SSR has a lot of advantages:
- Always up-to-date content
- SEO support
- Fast First Contentful Paint (LCP)
- Easy to get great Largest Contentful Paint (LCP) and Cumulative Layout Shift (CLS) metrics
- Consistently good API requests timings on the server-side
- Minimal client network requests waterfall because all required page resources (JS, CSS) will already have been added to HTML
SSR also brings some challenges:
- Slow Time to First Byte (TTFB) (
tramvai
doesn't support Streaming Rendering which can improve this metric) - More complex infrastructure (monitoring, logging, deployment, scaling)
- High server load when generating HTML
To be able to better handle high loads, tramvai
provides a few additional page render modes, which allow the server to do less work when generating HTML - static and client modes. Also, lazy hydration is available to improve client-side loading performance.