no-router-instance.mdx
title: No Router Instance
Why This Error Occurred
During Prerendering (SSR or SSG) you tried to access a router method push, replace, back, which is not supported.
Possible Ways to Fix It
In a function Component you can move the code into the useEffect hook.
In a class Component, move any calls to router methods to the componentDidMount lifecycle method.
This way the calls to the router methods are only executed in the browser.
Rendered from the public repository vercel/next.js on GitHub; content belongs to its authors. Cached for up to an hour.