Astro ships a built-in SPA router called ClientRouter. It intercepts navigations, swaps the DOM in JavaScript, and fires its own lifecycle events — giving you smooth transitions, prefetching, and persistent elements across page loads. For a complex app with shared state across routes, that JavaScript layer earns its keep. For a blog, it turned out to be a JavaScript solution to problems the browser now solves in CSS and HTML. Cross-document view transitions, link prefetching, animated element morphs — all of it ships natively, with no client-side routing, no lifecycle events, and no DOM mutation on navigation. And removing the JavaScript layer fixed a real bug in the process. The trigger: iOS Safari Reader Mode iOS Safari's Reader Mode reformats pages for distraction-free reading. It works by observing the DOM and rewriting it into a clean reading view. ClientRouter works by intercepting navigations, fetching the new page's HTML, and swapping parts of the DOM in place. Those two…
No comments yet. Log in to reply on the Fediverse. Comments will appear here.