Using useRouter with edge runtime leads to this error: Error: invariant expected app router to be mounted #56432
Labels
bug
Issue was opened via the bug report template.
Linking and Navigating
Related to Next.js linking (e.g., <Link>) and navigation.
Runtime
Related to Node.js or Edge Runtime with Next.js.
Link to the code that reproduces this issue
https://github.com/joncoronel/testing-next
To Reproduce
<html>
element.Current vs. Expected behavior
Using edge runtime on a route/page and then using
useRouter
in a client component within that page should not lead to any error. Currently it causes both an error in the dev server logs and also causes an error in the page html element on initial load or reload:<html id="__next_error__">
. It disrupts the loading of fonts since they are passed as variable in the html element.Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
App Router, Middleware / Edge (API routes, runtime), Routing (next/router, next/navigation, next/link)
Additional context
This error has been occurring since next 13.4.8. I tested 13.4.7 and it does not have this error. I also updated to 13.5.4 and the issue is still present as well as the latest canary build.
This error specifically occurs when using edge runtime and useRouter. Removing either of them removes this error.
The text was updated successfully, but these errors were encountered: