for anyone using appRouter (next.js 13+), use window.history.replaceState
instead.
from the docs:
Next.js allows you to use the native window.history.pushState and window.history.replaceState methods to update the browser's history stack without reloading the page.
window.history.replaceState({}, '', `/products?sort=xxx`)