JSFiddle - React, Tailwind, and code Playground

HTML

<button>Increase</button>click back button to decrease
<span id="counter">0</span>

JavaScript

$("button").click(function(){
    var count = +$("#counter").text() + 1;
    history.pushState({count:count});
    $(counter).text(count);
})
$(window).on("popstate",function(e){
    console.log(e);
    if (e.originalEvent.state)
        $(counter).text(e.originalEvent.state.count);    
})