Skip to content

The landing page, the templates gallery and the Angular page are sent as static HTML, and the browser takes each over as it was sent (0243) - #360

Merged
sharkysan merged 1 commit into
mainfrom
feat/the-landing-page-is-sent-as-static-html
Nov 26, 2026
Merged

sharkysan merged 1 commit into
mainfrom
feat/the-landing-page-is-sent-as-static-html

Conversation

@sharkysan

Copy link
Copy Markdown
Owner

The landing page, the templates gallery and the Angular page were each an empty <div id="root"> that a script drew into. A crawler or link preview that runs no script read only the head. It missed the landing page's argument, its section on the paid modules with their terms, its footer links, every template and the Angular page's code. 0242 rendered only the product pages and listed these three as debt.

What changes:

  • apps/site/src/render.tsx replaces product-render.tsx and lists every page of the site's build in STATIC_PAGES. prerender.mjs, the step 0242 added, writes each page into its root.
  • Every entry takes the markup over through mount (src/mount.tsx). It uses hydrateRoot over the markup with the same <StrictMode> tree, and createRoot on the dev server, where the root is empty. ?og empties the root and draws the card.
  • No component had to change. Nothing reads the browser, the address or the clock while rendering.
  • A <noscript> line says what needs the script.

Constraint: the site's policy admits no style attribute. A style in a page's first render is therefore refused when the page is parsed, and hydration does not write it again. Such a style has to be a class.

Guards, each watched failing on a planted fault:

  • pnpm build:web refuses a page whose root holds no page, or whose markup carries a style attribute.
  • apps/site/src/render.test.tsx renders each page as Node does: no browser globals, at another time and in another time zone. It then hydrates the page in React's development build with a media query and observers present, and fails on anything React reports.
  • pnpm test:browser reads the pages from the build. It fails a page whose top-level elements are not the ones the server sent, or that threw or logged an error, and checks that the examples, the journey and ?og still work.

Cost, measured 2026-11-26 (gzip level 9):

  • the landing page's HTML grows from 1,975 to 12,316 bytes;
  • the gallery's from 1,246 to 4,705;
  • the Angular page's from 1,012 to 3,648.

Not covered: React's production build silently keeps an attribute that differs between markup and first render for a reason none of the tests models, for example ICU or the visitor's language (§11). No @formancy/* package changes.

… as static HTML, and the browser takes each over as it was sent (0243)

The site's build now renders every page it builds into its root, using 0242's prerender step from one render module, src/render.tsx. Every entry takes the markup over through one mount(): hydrateRoot over the markup, createRoot on the dev server. ?og replaces the page with the share card. A crawler or link preview that runs no script now reads each page's words, links and modules' terms, not only its head.

build:web refuses a page whose root holds no page, or whose markup carries a style attribute, which the site's policy refuses and hydration would not write again. render.test.tsx renders each page as Node does, without browser globals and at another time and zone, then hydrates it in React's development build. The browser gate reads the pages from the build and fails one that React drew again instead of taking it over.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 44.44444% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
apps/site/src/mount.tsx 14.2% 5 Missing and 1 partial ⚠️
apps/site/src/product-main.tsx 0.0% 2 Missing ⚠️
apps/site/src/angular-main.tsx 0.0% 1 Missing ⚠️
apps/site/src/templates-main.tsx 0.0% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@sharkysan
sharkysan merged commit 987f3fb into main Nov 26, 2026
15 checks passed
@sharkysan
sharkysan deleted the feat/the-landing-page-is-sent-as-static-html branch November 26, 2026 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants