PWAs have their own back button (in html) and navigation, It is often different from history, and represents a hierarchical structure of content.
It would greatly improve the UX if we could set the OS back button on mobile (and maybe the browser back button on desktop) to the same value as the inner website navigation.
I know about that, but it is really a mess, complex and with many caveats. Settings the back url in a hierarchical navigation would be extremely easy and error proof.
Yes, it would be perfect if it allows you to decide the destination URL. Basically I want to sync the behavior of my custom back button (in the PWA top nav) with the OS navigation.
Custom back buttons are an absolute anti-pattern. Their only tolerable function is history.back().
That being said, when you say āhierarchical structure of contentā, it sounds as if you really mean an app-static previous item as in rel=prev or parent as in rel=up and not a use-dynamic back state.
Users expect the ābackā button to be able to close <dialog> elements and other similar app-like functionality in web apps. To me that seems to be a reasonable way to meet user expectations, not an anti-pattern. However we have to put up with the messy history API to do that.
Theyāre not an anti-pattern, itās what an average user expects. A user doesnāt expect that clicking the back arrow inside the HTML or the back arrow provided by the mobile OS gives him different results.
Think to apps like Whatsapp or Gmail: you expect that back always beings you to the global listing of emails / conversations if you are on a specific one. And that is indeed what happens:
Open Whatsapp
Open a conversation in Whatsapp
Click the top bar of the conversation to see Details about the group
Click the back arrow inside the app
You are now in the conversation: if you click ābackā on the OS you donāt go to the Details!! You go to the Whatsapp home (point 1)
So this is the proof that it is not an anti-pattern, and that it is widely used in native apps.
Users do expect that any back button takes them ābackā, indeed. What exactly they consider ābackā may differ (usually their previous view, i. e. the appʼs previous state, which may involve āclosingā active dialogs) and it may differ from the authorʼs idea of ābackā. Users are always confused if there are two back buttons (or any other duplicate control) and they are even more confused if those work differently. So, Iʼm in total agreement with:
A user doesnāt expect that clicking the back arrow inside the HTML or the back arrow provided by the mobile OS gives him different results.
and the way to fix this is either not providing any āback arrow inside the HTMLā or making its only ever action history.back(). Thatʼs simply the other way around from:
It would greatly improve the UX if we could set the OS back button (ā¦) to the same value as the inner website navigation.
As has been said, if you cannot be RESTful for some reason, there is already an API (pushState(), replaceState()) to add PWA views or states to the browser history ā actually there are two, the other being window.location.
If you are actually talking about previous / next relationships, like I mentioned, then you are really asking for new browser UI controls (which I would support). Opera and early Firefox used to support rel link relations that way.
That is the correct way to build PWAs: they must always show a back button and it does not represent history⦠If you are still not sure please read this:
So, saying that the back button in a PWA should always trigger back is wrong.
Example:
User visits category A
User visits item I
User visits a view to edit item I
User is now redirected to item I
The back button in the PWA points to category A, not to edit, as it would happen in any native app
We may actually have a whole bunch of ābackā actions, which must be coordinated and should not mismatch:
system button (hardware or software)
browser button
in-app button
swipe gesture (or keyboard shortcut, like Alt+Left-Arrow, Backspace or Ctrl/Cmd+B)
From the article, emphasis added:
Some might argue that because Android provides a back button through the device itself, then there is no need to replace the browserās back functionality. In fact, the two interactions do different things. Most apps continue to offer a back button in the header as an āupā action, to navigate within the hierarchical relationship between pages. The systemās back functionality might close a modal window or navigate to a different app entirely.
You are indeed talking about rel hierarchies, which are still underdeveloped in HTML (whereof prev does not really apply here), despite early attempts for standardization, which explicitly reserved back for browser history. So please use a different, unambiguous term, e. g. return.
After some months of observation of real people using our PWA I can say with confidence that, for non-tech users, having an in-app navigation (with hierarchy) different from the native back button is really confusing.
It would be extremely useful and simple for an app to manage the back event directly, for example, in order to build a hierarchical navigation.
The browser history API is difficult to use for hierarchical navigation, itās not meant for that.
If we want to use the same patterns of native apps inside PWAs browsers should add support for this.
Itās really frustrating that we cannot match the back button in the app with the browser back button.
This is especially useful when you have a hierarchical / folder navigation.
You donāt want the back button of the browser to go back in history to an edit screen for example⦠You just want to go back / up in the hierarchy. That is what a user expects and this is not currently possible on the web.
Itās not a big deal⦠Itās already the same for native apps and if we want to move the web forward we need the same capabilities (otherwise the user experience for native apps will be always superior for the average user).
For example:
Open a link to a Whatsapp number
The chat is displayed
If you click Back, you go to the Whatsapp home, not to the page containing the link
However this is not a problem for the average user because if you click again Back then you go back to the original page containing the link.
If you really want more control you can, for example, allow the web app to set the back URL only to a URL that has already been visited, otherwise you simply ignore the back URL suggestion.
window.ongoback = function() {
// find the previous URL based on app logic, navigation or hierarchy
// and return the hint to the browser
var back = "/back/to/this/page"
return back;
};
Then the browser goes back in the history up to that page (if itās not found then the browser can ignore the hint).This would be extremely simple, powerful and secure (even more than the current history api).
If you are curious about what I mean when I say āhierarchical navigationā based on app logic, you can try to create a (free) menu with our app: https://buonmenu.com When you are inside the admin area you will see that the āhierarchical navigationā (menus ā categories ā items ā edit) is a concept not easily manageable using the history api.
You can also browse native apps like Instagram and you will notice that the OS back button always match the in-app back button!
In these native apps the back button does not match the navigation history! Instead, it matches the navigation hierarchy (e.g. think to that as a back in a breadcrumb navigation).
As I explained above we could achieve the same for the web and greatly improve the UX for web apps, without any security concern. So why not give this option to developers and UX designers?
Reading posts like the following (with 500k+ views) make me think that the browser back button, in the current state, is something legacy that causes several issues to modern apps:
My proposal would solve all these use cases with simplicity, interoperability and security.