Invalid HMR message..Error: No router instance found. ???
See original GitHub issueWhat 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:
- Created 2 years ago
- Reactions:52
- Comments:42 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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…
I am facing the same issue.