Currently, I am facing a challenge in changing the route of a Next.js application using vanilla Javascript. In order for the code to be compatible with Chrome Dev Tools, I cannot dynamically change the route with Next.js and instead must find a solution using plain Javascript.
In previous experiences with Vue.js applications, I successfully changed routes using the following code:
window.history.pushState({}, '', '/directory');
window.dispatchEvent(new Event('popstate'));
However, it seems that this approach does not work with Next.js applications. I am searching for an alternative method to achieve the same result. I believe the solution may be similar to the Vue.js example, but I have not yet found the correct implementation.