Next.js Discord

Discord Forum

NextJS 15 - React 18 or 19?

Unanswered
Golden northern bumble bee posted this in #help-forum
Open in Discord
Golden northern bumble beeOP
The docs say react 19 is minimum version required. When I use react 18 in my package json, my builds run fine. When I use 19, my builds fail with a bunch of random errors.

I have run all the codemods, and I dont think there is a context error present. What do I do?

TypeError: Cannot read properties of null (reading 'useContext')

Resolving 'react-dom/package.json' in /Users/jpetrillo/Documents/Projects/tarkov-directory/node_modules/next/dist/build for build dependencies doesn't lead to expected result '/Users/jpetrillo/Documents/Projects/tarkov-directory/node_modules/react-dom/package.json', but to '/Users/jpetrillo/Documents/Projects/tarkov-directory/node_modules/next/node_modules/react-dom/package.json' instead. Resolving dependencies are ignored for this path.

Resolving 'react/package.json' in /Users/jpetrillo/Documents/Projects/tarkov-directory/node_modules/next/dist/build for build dependencies doesn't lead to expected result '/Users/jpetrillo/Documents/Projects/tarkov-directory/node_modules/react/package.json', but to '/Users/jpetrillo/Documents/Projects/tarkov-directory/node_modules/next/node_modules/react/package.json' instead. Resolving dependencies are ignored for this path.

18 Replies

It must be because of breaking changes of React v19
https://react.dev/blog/2024/04/25/react-19-upgrade-guide#breaking-changes
I would recommend you to stay at Next.js v14
Golden northern bumble beeOP
I ran the codemods and skimmed the breaking changes. Nothing should be broken, its strange
Not only your codebase but what about the libraries you are using?
Golden northern bumble beeOP
true, but shouldnt I be getting a peer dep error if they are requiring a specific react version?
Maybe bun is not good at that
yeah I assumed you installed by --force or --legacy-peer-deps
Golden northern bumble beeOP
Nope, just "bun install"
I am going to try npm
yeah, try with npm
Golden northern bumble beeOP
yeah then probably that must be the issue I think
Golden northern bumble beeOP
used bunx check-peer-dependencies for anyone else that comes across this
for what, are you upgrading Next.js v15?
Golden northern bumble beeOP
also installed 19.0.0-rc-02c0e824-20241028 as exact version next wanted (I guess I was on a different rc version)
@James4u for what, are you upgrading Next.js v15?
Golden northern bumble beeOP
Just to upgrade since they said it was stable
well, I won't be using Next.js 15 for my production
React 19 is not stable yet, most of libraries are not compatible with React 19
I would say v15 will be "stable" when they release v16 🤣