#Programmatic API for the client-side router

13 messages · Page 1 of 1 (latest)

formal hill
#

Hey all, I’m playing around with the new client-side router & View Transitions, and I’m wondering if there are plans for a programmatic API to trigger a page navigation?

Currently, setting the ‘location.pathname’ directly performs a full page reload. Generally this would not be a big deal, but I’m trying to have a persistent component across all pages (a toast, basically). I can manually create an anchor element and click it via a script to fake it though.

civic deltaBOT
#
Quiet in here?

It looks like no-one has responded to your question yet. People might not be available right now or don’t know how to answer your question. Want an answer while you wait? Try asking our experimental bot in #1095492539085230272.

rotund tapir
#

Hi @formal hill, yes calling .click() on an anchor is currently the only way to trigger the client-site router from JavaScript.

formal hill
#

Got it, thanks! Do you know if a programmatic API is in the works?

rotund tapir
lunar moat
#

thanks

rotund tapir
rotund tapir
#

@formal hill 👆

formal hill
#

Oh nice, thanks 😄

lunar moat
#

@rotund tapir thanks

rotund tapir
#

@formal hill update: Router API is available with Astro 3.2

#

@lunar moat thank you 🙂

formal hill
#

That is awesome! I was super excited when I saw the latest release notes. I’ve started using it already!