SSR / Pages that work without JavaScript
How GET, POST, and hydration share one owner map
| Part of the page | Owner | Behavior without scripts |
|---|---|---|
| HTML document | foldkit-ssr (SSR.render) | Full page rendered from init |
| Server data | foldkit-remote (Data.satisfy, Remote.resume) | Data already embedded in HTML |
| Search, filters, sort, page | foldkit-mirror (Mirror.url) | GET forms and links update the URL |
| Virtualized list window | foldkit-mixins-ui (WindowList) | One visible window paged by links |
| Mutations (such as add to cart) | update via fallback: 'server' | Form POST runs update on server |
| Scripted vs plain controls | Style.media('(scripting: none)', …) | Only plain HTML controls display |
| Cross-request state | Your app (cookie or database) | Read in prepare, written in headers |
Both scripted and unscripted paths share one Model, one update, and one
view:
- GET
/?q=acme&sort=PriceAscending:Mirror.reducereads query params intoinit,prepareloads the cart cookie and runsData.satisfy, andSSR.renderemits HTML plus the resume envelope. When scripts boot,SSR.hydrateresumes thatModelwithout re-fetching. - POST
/?q=acme(scripts off):SSR.entryverifiesOrigin, rebuilds theModelviainitandprepare, decodesfoldkit-plus-message, runsupdate(Message), writes the updated cookie header, and redirects (303) back to/?q=acme. With scripts on, the browser handlesOnSubmitlocally.
Six rules follow:
- Render every shown value in the HTML before sending the response.
- Keep GET state in the URL using
Mirror.urland<form method="get">. - Draw both scripted and plain controls and toggle them with CSS
(scripting: none)rather than<noscript>. - Page virtualized lists with links (
WindowList.pageOf) so users can step through windows without JavaScript. - Express mutations as
rh.formsubmissions carrying a typedMessage. - Test both modes: verify the workflow with JavaScript disabled, and verify
hydration produces zero warnings or form
POSTs with JavaScript enabled.