diff --git a/errors/popstate-state-empty.md b/errors/popstate-state-empty.md index 1268e15c0b036..ccd98713a557d 100644 --- a/errors/popstate-state-empty.md +++ b/errors/popstate-state-empty.md @@ -2,12 +2,12 @@ #### Why This Error Occurred -When using the browser back button the popstate event is triggered. Next.js sets -`popstate` event triggered but `event.state` did not have `url` or `as`, causing a route change failure +When using the browser back button the popstate event is triggered. Next.js sees a +`popstate` event being triggered but `event.state` did not have `url` or `as`, causing a route change failure. #### Possible Ways to Fix It -The only known cause of this issue is manually manipulating `window.history` instead of using `next/router` +The only known cause of this issue is manually manipulating `window.history` instead of using `next/router`. Starting from version 9.5, Next.js will ignore `popstate` events that contain `event.state` not created by its own router. ### Useful Links diff --git a/packages/next/next-server/lib/router/router.ts b/packages/next/next-server/lib/router/router.ts index 5475c2399b9d9..b6ac61c8ee242 100644 --- a/packages/next/next-server/lib/router/router.ts +++ b/packages/next/next-server/lib/router/router.ts @@ -360,13 +360,6 @@ export default class Router implements BaseRouter { return } - if (process.env.NODE_ENV !== 'production') { - if (typeof url === 'undefined' || typeof as === 'undefined') { - console.warn( - '`popstate` event triggered but `event.state` did not have `url` or `as` https://err.sh/vercel/next.js/popstate-state-empty' - ) - } - } this.change('replaceState', url, as, options) }