Set back button URL in PWAs

Furthermore, installed PWAs can already hide the browser back / forward buttons with “display”: “fullscreen” in the manifest and have their own back button (even Google Ads console has its own custom back buttons). That means that the browser control is redundant and confusing for most web applications. I don’t say to remove it, but at least to give a little more control to developers… otherwise the end users get confused.

Here’s other issues caused by back buttons (and all the terrible workarounds):

Its 2022, I am extremely confused as to why the others on here cannot see that what @collimarco is saying not only makes sense, but should be very easy to implement. This will make PWAs navigation be similar to native. Sadly i have to now investigate history api.

1 Like

It’s 2022 and it’s still complicated to solve this problem.

I have an application that displays dialogs where users are always confused, and instead of clicking “OK” or “CANCEL” in the modal dialog, they press the back button, changing pages and sometimes losing what was typed.

I had to create a solution with # in the URL and listen to the changes to know what to do, extremely complicated to maintain.

window.ongoback = (event) => {
  // Exemple of implementation when dialog is open
  if (dialog.isOpen) {
    // Do something

  var back = "/back/to/this/page"
  return back;

There’s been some movement on new APIs for back handling.

Close watcher in particular maps the browser back button on mobile to “close” semantics, which looks like it would satisfy your use case of having the back button close your dialog?

Unfortunately no.

All these solutions are made for SPA and apps built mainly with frontend frameworks.

If you have an app built with normal HTML pages rendered server-side, all these solutions are a nightmare and cannot be used.

Example: you have a navigation of a hierarchy (like folders and files) and edit/delete buttons on each element.

I really don’t understand why browsers are not adopting a simple solution like the one that I proposed above.

Simple, intuitive, and works for everyone… (and no, there aren’t any security concerns, as I explained above)