Many compose web applications samples don’t seem t...
# compose-web
j
Many compose web applications samples don’t seem to work with the browser back and forward navigation. Is this intentional? Can something be done about it
a
I would imagine this is working as expected. not sure this will be ever supported (or need to be supported). you can probably detect the back button clicks on the browser if there is such an API from javascript though
e
@Alex Styl isn't it pretty much the same case as for SPAs? IIRC frameworks like Angular handles navigation in a custom way
a
@Edoardo Luppi havent used angular etc al so not sure. i have used nextjs and i remember having some quirkiness towards back navigation
a
Most SPA web applications wrap the Browser History APIs to handle this. We rolled our own basic solution with a Compose HTML project
👍🏾 1
j
It's common in compose to find sites that have a top appbar so you have to navigate within the site but can't use the browser navigation. Terrible experience. Is there a way to at least make the navigation work together
d
Kobweb (a Compose HTML framework, so apologies if irrelevant to you here) supports what you want, in case you or anyone else wanted to copy the relevant code (or just use Kobweb 😜). The code has two parts: 1. It intercepts the
onpopstate
event to be informed when the user pressed back or forward. You can see that here. 2. When handling a request to navigate to a new page, it modifies the history stack directly by using the
pushState
or
replaceState
methods. You can see that here.
👍🏾 1
g