How gemkit renders a page
· 1 min readWhen a request arrives, gemkit renders the page with gem-ssr in a simulated DOM:
- The router matches the URL and loads the layout and page modules.
- The page's
*.server.tsloads data, the page'sloadoption can transform it on both sides. - Elements render, shadow roots are serialized as declarative shadow DOM.
The browser shows the HTML immediately. When the scripts arrive, elements are upgraded and reuse the existing DOM instead of rendering again, then navigation happens on the client.
Data loading
*.server.ts: runs on the server only, returns JSON, can usefs, databases and secrets.loadoption: runs on the server for the first request and in the browser for client-side navigation.
When the site is prerendered, the server data of each page is written next to its HTML as __data.json,
so client-side navigation works on a static host too.