MDN self-hosted library · e01.org

History: pushState() method

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
const state = { page_id: 1, user_id: 5 };
const url = "hello-world.html";

history.pushState(state, "", url);
js
const url = new URL(location);
url.searchParams.set("foo", "bar");
history.pushState({}, "", url);