Open igordanchenko opened 6 days ago
Just downgrade react to version 19 or 18. React isn't bundled into nextjs it's just a version number set in the package that npx create-next-app generates.
Thank you for the suggestion (though I'm not sure what you mean by downgrading react to 19, as 19 stable hasn't been released yet)
Yet the issue manifests itself out of the box with a brand new starter app created with the create-next-app
, and that's what this ticket is about.
p.s. To make it clearer, I've updated the issue description to avoid the word "bundled"
My bad, missed that. So you want it to work with latest react? Mui would have to update it's deps as nextjs is compatible with the react version you have.
My bad, missed that. So you want it to work with latest react?
Correct, since React 19 RC is officially supported in Next.js 15. Downgrading to React 18 would prevent developers from ensuring compatibility with the upcoming React 19 GA.
Mui would have to update it's deps as nextjs is compatible with the react version you have.
This issue is not limited to MUI. I mentioned react-hook-form
in the description as another prominent example. 3rd-party libraries with peer dependencies ^19
or >=18
won't install out of the box, and that's what this ticket highlights as an issue. The other workarounds I mentioned in the description are not entirely user friendly.
I'm just curious why Next.js team didn't add the following override to the create-next-app
template?
"overrides": {
"react": "$react",
"react-dom": "$react-dom"
}
Is there any downside to doing that?
did my suggestion work for you..??
Link to the code that reproduces this issue
https://stackblitz.com/edit/nextjs15-react-rc-peer-dep?file=README.md
To Reproduce
create-next-app
)npm i @mui/material
ornpm i react-hook-form
in the consoleCurrent vs. Expected behavior
Unable to install major packages with Next.js 15 due to
react
RC peer dependency.npm install
fails with the "Could not resolve dependency" error (see repro above).For example,
@mui/material
uses the following React peer dependency range -^17.0.0 || ^18.0.0 || ^19.0.0
, which fails with the React RC version installed by default from Next.js 15 peer dependencies. The same issue happens withreact-hook-form
and^16.8.0 || ^17 || ^18 || ^19
peer dependency range, and also other packages using>=18
peer dependency range.I'm aware of the following workarounds, but it seems like a major inconvenience and really a blocker for inexperienced developers.
1) Install with
--legacy-peer-deps
flag:2) Add React version overrides to
package.json
:or
3) Downgrade
react
to 18Provide environment information
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local)
Additional context
I've also tested with the latest canary (15.0.2-canary.10) and observed the same issue.