Site / With Remote and SSR

Site, Remote and SSR together

A server-rendered page with data usually does its work twice. The server fetches and draws the page, then the browser boots, fetches the same data again, and redraws. Meanwhile the router, the data layer and the renderer each keep their own idea of which page is showing.

Three packages split that job by question:

  • foldkit-site answers where the reader is and what surrounds the page.
  • foldkit-remote answers what the page reads from the server, and what the Model already knows.
  • foldkit-ssr answers how a page the server drew becomes the browser's without doing the work again.

They meet in two places only: the application's Model, which holds the route and Remote's store side by side, and one record of Surfaces, which says what each page reads. Site makes that record from the tree, Remote fetches what it asks for, and SSR checks that the page it hands over carries all of it.

This guide builds one small application with all three: each owner's projects at /owners/<id>, rendered on the server with its data, taken over without fetching again, built statically, and read ahead on hover. Every snippet compiles and runs in the Site package's own tests. The CMS example's public site is the same design at full size.