Does anyone know another way to make a button to go back to the previous page?

This code no longer works on my site, I used it…

import {session} from 'wix-storage';
import wixLocation from 'wix-location';

let previousPageURL;

$w.onReady(function () {
  previousPageURL = session.getItem("page");
  session.setItem("page", wixLocation.url);
});

export function btnBack_click(event) {
    wixLocation.to(previousPageURL)
}

The best way is to it is by adding a custom element to the page and use the browser api to go back based on the browser history (this way it will be in sync with the browser back and forward buttons).
please remind me tomorrow to elaborate (if the explanation above is not enough)