>>107538314
Also since you're making a SPA you will need to manage state. Also you need an event listener that fires on history.pushState()
Some extracts from an imageboard I'm working on:
let state = {selected_thread_id: null};
// [...]
window.history.replaceState(state, null, ""); // Initial state
window.onpopstate = function(event) {
if (event.state) {
state = event.state;
}
refresh_send();
}
// [...]
function openThread(thread_id) {
state.selected_thread_id = thread_id;
history.pushState(state, "", "_ROOT_URL" + "thread/" + state.selected_thread_id + "/");
getThreadPosts();
}