Skip to content

Blog

Static HTML for every route, then a router on top

Details
Date:
Author:
Noel Ruault
Topics:
Vanilla TypeScriptPerformanceInfrastructure

The build writes one HTML file per route from the same templates the client router renders. Deep links work without JavaScript, and an in-app navigation produces the exact DOM a cold load would.

Client-side routing is usually where a static site stops being static. The fix is to make the router a consumer of the build rather than a replacement for it: templates are plain functions returning strings, the build calls them once per route and writes the files, and the browser bundle calls the same functions when the user clicks.

Because both paths render identical markup, there is no hydration step and no mismatch to debug. The dev server imports the same templates, so dev and live pages cannot drift either.

All posts