microsite router
vincent-vade opened this issue · comments
Hi,
Firstly good stuff for this alternative to Next...
I've one suggestion for the next release it should be cool to add built-in Router like next/router ?
Like gettings route params in pages or components with useRouter
It's in the plans ?
Regards,
Vincent
I don't have plans to include a built-in client-side router, but exposing the route context in pages/components is definitely a great idea. I have a few ideas on how that could be accomplished.
A client-side router doesn't mesh well with the philosophy behind Automatic Partial Hydration. To Microsite, your pages are not a single Preact app like a typical SPA router expects. Rather APH splits your page into many small Preact apps responsible for rendering a shallow tree of components. See Jason Miller's article on Islands Architecture.
I've experimented with using Google's quicklink
in src/global/index.ts
and it works like a charm. I might be able to make some optimizations and bake in a similar link rel="prefetch"
behavior, since Microsite knows precisely what links appear on any rendered pages.