"Go to previous page" only if previous page is in the app?

In our app we have a “back” button in the nav bar that goes back to the previous page. However, it’s possible (and desirable for us!) that a user could land on that page directly from google (or wherever). In this case we want the back arrow to go to the home screen.

Is that possible?

Couldn’t you go to the index page? Or am I misunderstanding you?

Sorry, I didn’t explain that well.

If a user comes directly to a page from google (say to the url myapp.com/details/123) - at the top of the “details” page there is a back arrow.

If you were using the app normally, then hitting “back” would go back to the home screen myappc.com/home - which is good.

BUT, if you came directly from Google then hitting back would take you back to google (because I think the “go to previous page” just does window.history.back() under the hood).

I want to so something like “Go to previous page, Only when previous page is a page in my app”.

I used the plugin Browser Storage (kind of cookie storage) to check the status of a user (or new user), and act on it.

1 Like