JSFiddle - React, Tailwind, and code Playground
HTML
<button id="_btn">
>>
</button>
<div id="_out">
</div>
CSS
#_out {
margin-top: 1rem;
border: 2px solid tomato;
padding: 1rem;
}
JavaScript
window.onload = () => {
history.pushState(null, null, '/1')
_out.textContent = location.pathname
}
_btn.onclick = () => {
let page = +location.pathname.replace('/', '') || 1
page++
history.pushState(null, null, '/' + page)
_out.textContent = location.pathname
}
window.onpopstate = e => {
_out.textContent = location.pathname
}