2023-07-05 15:11:16 +02:00
|
|
|
---
|
|
|
|
title: No Router Instance
|
|
|
|
---
|
2019-03-07 17:13:38 +01:00
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
## Why This Error Occurred
|
2019-03-07 17:13:38 +01:00
|
|
|
|
2021-01-26 11:27:53 +01:00
|
|
|
During Pre-rendering (SSR or SSG) you tried to access a router method `push`, `replace`, `back`, which is not supported.
|
2019-03-07 17:13:38 +01:00
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
## Possible Ways to Fix It
|
2019-03-07 17:13:38 +01:00
|
|
|
|
2021-01-26 11:27:53 +01:00
|
|
|
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.
|