next.js: Minified React error #310: Rendered more hooks than during the previous render.
Link to the code that reproduces this issue
https://github.com/moroshko/rendered-more-hooks-issue
To Reproduce
Once the application is started in Dev mode, and http://localhost:3000 is visited, the following error appears:
Application error: a client-side exception has occurred while loading …
and the console shows:
Rendered more hooks than during the previous render.
Then, the error magically disappears and the page is rendered as expected.
Visit here to experience this yourself.
Current vs. Expected behavior
There should be no error.
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 24.4.0: Wed Mar 19 21:16:31 PDT 2025; root:xnu-11417.101.15~1/RELEASE_X86_64
Available memory (MB): 16384
Available CPU cores: 12
Binaries:
Node: 22.11.0
npm: 10.8.1
Yarn: 1.22.22
pnpm: 9.14.2
Relevant Packages:
next: 15.4.0-canary.2 // Latest available version is detected (15.4.0-canary.2).
eslint-config-next: N/A
react: 19.1.0
react-dom: 19.1.0
typescript: 5.8.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Redirects, Server Actions
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed)
Additional context
If I do any of the following, the issue is gone:
- Remove
redirect("/dashboard")on the Home page and render some HTML instead. - Replace
<Suspense>with a<div>inSignedInLayout. - Don’t call the
getAuth()server action inProviders.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 15 (5 by maintainers)
Running into this issue as well on
15.1.2, similar cause to what @glekner discovered. One of our client context providers in our root layout file fetches some data and then updates its internal value with whatever it got from the server. This fetch is done via a server action which does no mutations, just fetches some data.Though, while the layout client component is fetching its data a redirect happens, and causes this error.
Next Info: