provides an experimental turbo mode that enables SPA-like navigation.
It combines techniques from quicklink
and @hotwired/turbo
, but taking advantage of the architecture of every site to achieve it in under 2kb.
You can see it in action in this site!
quicklink
@hotwired/turbo
In most sites, standard navigation should already be quite fast given allows you to generate sites without any blocking JS, and the interactive pieces are prerendered at build time.
However, since it's very lightweight, it's compatible with the standard lifecycle of any of the supported frameworks, and it will progressively enhance the site, you can use it whenever a snappy navigation is preferrable.
Caveats
- All
script type="module"
execute once- For islands, use the lifecycle of each component as usual (
onMounted
,onUnmounted
)- In client scripts, use the
onLoad
callback for effects that should run on every page load- Code outside components or callbacks won't run on each page navigation
- Add the
once
attribute to non-module scripts that should only execute once
Roadmap 🛣It's possible to avoid unmounting islands that don't change from one page navigation to the other, making them automatically "permanent" (in the
@hotwired/turbo
terminology) without any intervention from the user.That would allow persistent components typically found in SPAs like shopping carts to work seamlessly.