1// Construct URLSearchParams object instance from current URL querystring.
2var queryParams = new URLSearchParams(window.location.search);
3// Set new or modify existing parameter value.
4queryParams.set("myParam", "myValue");
5// Replace current querystring with the new one.
6history.replaceState(null, null, `?${queryParams.toString()}`);
7// Or create new history entry with push state
8history.pushState(null,null, `?${queryParams.toString()}`);