Changing Next.js route with vanilla Javascript

I need to change the route of a Next.js application using vanilla Javascript. I want this code to work on Chrome Dev Tools so I cannot change the route dynamically with Next.js so I have to achieve this with plain Javascript.

I was able to do this on Vue.js applications like this:

window.history.pushState({}, '', '/directory');
window.dispatchEvent(new Event('popstate'));

Unfortunately popstates are not working on Next applications. I need a wayaround to that, I’m sure the code should resemble the Vue.js example, but I cannot figure that out.