SSR / Pages that work without JavaScript
The mental model
GET /?q=acme&sort=PriceAscending
Mirror.reduce ─▶ init ─▶ prepare (cookie, Data.satisfy) ─▶ render whole ─▶ HTML + envelope
scripts on: SSR.hydrate resumes the Model; nothing is read again
POST /?q=acme (foldkit-plus-message = the form's encoded Message)
Origin checked ─▶ init, prepare, as for the GET ─▶ update(Message)
─▶ 303 to /?q=acme, with the cookie written from the Model it reached
scripts on: the runtime answers the submit; nothing is postedSix rules follow from it:
- Everything shown is in the HTML. Read before the render, so no row waits for a script to price it.
- The address is the state a GET carries. Search and filters are a GET form over the keys the URL mirror reads.
- Both kinds of control are drawn on both sides. The plain ones show
under
(scripting: none), the scripted ones otherwise, so the browser's first render is the page the server sent. Never<noscript>. - A virtual list pages by links. Without scripts it draws one window, so it links to the next.
- A change is a form whose submit is a Message. The runtime answers it when it runs; the server answers the post when it does not.
- A test runs with JavaScript off, and another checks that the scripted page did not change.