JSFiddle - React, Tailwind, and code Playground
HTML
<div id="state">initial</div>
click some of these links, then click back button<br>
<a href="one">one</a><br>
<a href="two">two</a><br>
<a href="three">three</a><br>
<a href="four">four</a><br>
CSS
div{background:#ddd;height:30px;}
JavaScript
$('a').click(function(e){
e.preventDefault();
var d = this.href;
window.history.pushState({data: d}, d, d);
$('#state').text(d);
});
$(window).on('popstate', function(e){
var d = e.state || {data: 'no state'};
$('#state').text(d.data);
});/**/