BGoole's avatar

How to prevent/disable the back button on a browser using Laravel

I built an order system for a tablet. Because it's a web app (Laravel Breeze), I'm worried that if users press the back button—on the OS or browser—it could crash the system. How do i prevent/disable the browsers backbutton and the Tablet back button.

0 likes
2 replies
JussiMannisto's avatar

You can't prevent it, and you shouldn't try to. You have to make the app more resiliant. There are countless order systems on the internet, and they don't crash on back navigation.

2 likes
martinbean's avatar

@bgoole You don’t. The back button is part of the browser. The user and their operating system is in charge of it; not your web app.

If your web app “breaks” when navigation backwards and forwards then fix that, instead of trying to hijack native functionality. You should be maintaining state in your application, and checking that state on each page load.

Please or to participate in this conversation.