Cushty's avatar

Inertia back button on mobile

Hi, i've noticed on mobile if a user navigates to different pages then presses the back button it actually comes out of the web app, ive noticed it on Laracasts as well, is there a way to keep history or another workaround on mobile using Inertia? Thanks

0 likes
6 replies
JussiMannisto's avatar

What do you mean by "coming out of the web app"? Page history should work normally regardless of device.

Cushty's avatar

Hi, I mean, say i was on website A, i go to website B, on website B I am going to different routes, i press the back button on mobile, I am taken back to website A like the whole web app of website B was a one page SPA. Thus sending me back not to a aoge on website B but back to website A, if you get what i mean. Thanks

DigitalArtisan's avatar

More than likely website B is a Single Page Application(SPA), so clicking back will take you to website A.

Cushty's avatar

Nope, the website is using Laravel, Inertia, React and SSR. I tested on a new iPhone and Chrome and it works fine, on an older iOS 18 iPhone, the issues happen. I've also noted if a site is not using full SSR, it works normally even on iOS 18, but my app has SSR enabled, and it has the issue.

JussiMannisto's avatar

That sounds weird. There should be no difference between SSR and CSR in this regard. I've run both kinds without seeing any history issues.

Maybe your UI uses some JS feature or library that isn't supported on the older mobile browser, which then causes errors? The history API updates would have to fail somehow for this to happen. Have you checked if the address bar updates when you navigate between pages on site B?

DigitalArtisan's avatar

This is a common gotcha when using Inertia.js on mobile browsers (especially Safari on iOS and some Android OEM browsers).

Your Inertia navigation didn’t create real browser history entries. The native back button sometimes closes the browser tab instead of navigating back through Inertia’s history.

More of an issue with IOS.

Please or to participate in this conversation.