question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid HMR message..Error: No router instance found. ???

See original GitHub issue

What version of Next.js are you using?

12.0.1

What version of Node.js are you using?

17.0.1

What browser are you using?

Chrome / Safari

What operating system are you using?

macOS

How are you deploying your application?

dev

Describe the Bug

While loading in locally developed npm packages, I get a weird warning in the console: [Warning] Invalid HMR message: {"action":"sync","hash":"","warnings":[],"errors":[]} Error: No router instance found. You should only use "next/router" on the client side of your app.

This current app is a test app that has no router instance anywhere, its just one page so the error doesn’t really make sense. The npm package is adding styles to the _app.tsx (global style) and an Icon component to the index.tsx file.

Chrome gives the same warning only on initial load but the warning goes away after that

Expected Behavior

The expected behaviour would be no hmr warning

To Reproduce

Not sure how others can reproduce the error since its kinda random

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:52
  • Comments:42 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
snowytimecommented, Nov 2, 2021

Its also strange cause I am not actually using the router at all in my test app 😕 like not once is useRouter called in the entire application…

6reactions
flowckcommented, Nov 1, 2021

I am facing the same issue.

  • Next 12.0.2
  • MacOS 11.6
  • Firefox
  • Node 15.2.0
Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.JS Error: No router instance found - Marcusoft.net
So this error even has an page on the Next. JS site and it's helpfully trying to tell me that I'm using the...
Read more >
Invalid HMR message error Webpack - Stack Overflow
I'm getting the following error from Webpack: Invalid HMR message Followed by a string of very detailed JSON.
Read more >
Error: No router instance found. You should only use “next ...
You should only use “next/router” inside the client side of your app. this error it happens when you try to use next/router inside...
Read more >
Troubleshooting - Vite
Error : Cannot find module 'C:\foo\bar&baz\vite\bin\vite.js' #. The path to your project folder may include & , which doesn't work with npm on...
Read more >
Header Manipulation Rules Resource Guide
Note that the header instance functionality has no impact on HMR's add action, ... message-window” config attributes in session-router config.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found