Remote / foldkit-remote

Server rendering: Remote.resume

A snapshot is built for a cache that survived a reload: it keeps the whole entity store and deliberately no cursors. A page rendered a moment ago wants the opposite. Remote.resume(Data) is a resume part for foldkit-ssr (in development), which sends exactly what the page's active Surfaces read, and resumes it in the browser:

ts
const Page = SSR.plan(App, {
  id: 'project',
  state: Projection.pick(App.model.route),
  surfaces: [ProjectPageAt],
  parts: [Remote.resume(Data)],
})
  • Only what is read crosses. For each requirement, the fields it names, following its relations through the refs the store holds; for each connection, the fields its selection reads of each item. A field in the server's store that no Surface selects, such as a user's email, is not in the page.
  • Connections cross whole, with their boundaries, so "load more" knows where the server stopped.
  • Live cursors cross with the entities they follow, so a live subscription started in the browser asks from where the server's left off.
  • Nothing else crosses. Loading marks, failures, the mutation ledger, optimistic layers, gaps and retention start at their initial values.

The browser's read entry plans against the restored store, so it asks for none of it again. The capture is JSON through its own Schema, and a page whose capture does not decode is refused whole by foldkit-ssr. Give a second domain in one application its own id: Remote.resume(Catalog, { id: 'catalog' }).