I have a Ionic Angular app for Android using Capacitor, but the same codebase also for PWA (web).
Now on a certain page I want to catch the default back event (when an user clicks in the browser).
Instead of going a page back I want to catch it and show an Alert (ionic Alertcontroller).
This alertcontroller is also shown when I hit the hardware back button on a mobile device.
What is the best way to archive this (only for the browser part). ChatGTP gave me an HostListener example, but that didn't work as expected. The alert was show, but the page was also going back.