I want to create a special navbar that has a back button inside of it. How can I redirect a user to the previous page? Is there a good way to do it and get the last page navigated from?
Check this JS Hook out. Or you can refactor to use AlpineJs if you are using that
I’m actually using AlpineJS already. You mean just using
@click="history.back()"? Is there a disadvantage to using this approach that you can think of?
Yeah, that should work!
I don’t really see any disadvantages, I guess I would need to know more whats going on/why you want this to be able to answer better, but I don’t think there would be any disadvantages
Also using Alpine.JS, this is what I do so the back button is only there for navigating internally within the site, and doesn’t send you to a different site (or to the ‘new tab’ page of your browser):