Useful or not, from you.
next.js Uncaught (in promise) Error: No router instance found. You should only use "next/router" inside the client side of your app.

Bug report

Describe the bug

next/router is not working as expected. Instead of redirecting, it is throwing the error mentioned in the title.

To Reproduce

  1. Just setup a new Next.js project by fetching next, react and react-dom.
  2. Create an index.js page with following code
import Router from 'next/router'

export default (props) => {
        Router.push('/hola')

        return  (
            <div>
                Hi
            </div>
        )
}

  1. It will throw this error

Expected behavior

It should show the 404 page as 'hola.js' is not there.

System information

  • OS: Ubuntu 18.10
  • Version of Next.js: 8.0.3
That's a useful answer
Without any help

Hi,

useRouter hook solved my problem. Can you look at Next.js official docs link: https://nextjs.org/docs#userouter