Make safari use normal `back` and `forward` button as other browser

Solution 1:

macOS doesn't natively support using mouse buttons for forward and back. You can use gestures if you have an Apple trackpad or a magic mouse, but not buttons.

However, there are a number of apps that will do this. One lightweight option is https://sensible-side-buttons.archagon.net/

P.S. I also have a personal fork of this app with some idiosyncratic features I wanted—e.g. hold down the middle mouse button while pressing a side button to use the side button's native behavior. https://github.com/Wowfunhappy/Side-Button-Enabler/releases/tag/1.1

Solution 2:

I used karabiner elements to map button5 to cmd+] and button 4 to cmd+[ (being forward and back) but used the "front_most_application_if" condition for it to be only active in safari so they are still the normal buttons in other apps.

The code I used:https://pastebin.com/LvpZRmee

Solution 3:

In System Preferences -> Keyboard -> Shortcuts -> App Shortcuts you can set shortcuts for Safari. Specify "Back" for the menu text and then select the "normal back" button. (What is this button? Do you mean the arrow keys? Mapping back to the back arrow could cause you to jump off of a page when you only intended to move your cursor back while typing some text in a web form.)