Last updated on
Was the page navigated to using back or forward button?
window.performance.getEntriesByType("navigation")[0].type === "back_forward";
This is how to detect if a page was loaded because the user navigated via back or forward buttons.
Possible values:
back_forwardif the navigation happened because of a back or forward navigationnavigateif the navigation happened because of a regular navigation event (like clicking a link).reloadafter reloading the pageprerenderif the navigation has happened during a prerender hint