Skip to content

feat: upgrade nextjs to v15#923

Merged
nikomakela merged 1 commit into
mainfrom
LIIKUNTA-768-upgrade-nextjs
Nov 26, 2025
Merged

feat: upgrade nextjs to v15#923
nikomakela merged 1 commit into
mainfrom
LIIKUNTA-768-upgrade-nextjs

Conversation

@nikomakela

@nikomakela nikomakela commented Nov 24, 2025

Copy link
Copy Markdown
Contributor

LIIKUNTA-768.

Upgrade using NextJS v15 with React 18 (by using codemod tools).

It should be noted that this is not a well supported or adviced combination by NextJS. There is no clear statement for supporting it -- only opposite.

See more:

  1. A blog post that suggests that there should be no issues: https://nextjs.org/blog/next-15#pages-router-on-react-18.
  2. An official documentation and migration guide, that clearly states that React v19 should be used:
    https://nextjs.org/docs/15/app/guides/upgrading/version-15#react-19.
  3. 3rd party blog that says it's okay to use React v18 with Pages router:
    https://www.wisp.blog/blog/can-nextjs-15-app-router-be-used-with-react-18.
  4. Yet another page in docs that states that it's okay to use React v18, even with NextJS v16: https://nextjs.org/docs/messages/react-version.
  5. NExtJS Github ticket to add support for React v18 when Pages-router is in use: Support React 18 in Pages Router vercel/next.js#69484

NOTE: The codemod fails when it was ran. No matter what is chosen for React v18, it is still upgraded. Similar experiments here: https://www.reddit.com/r/nextjs/comments/1gpb104/comment/lxw60lj/.


Step 1:

Upgrade the NextJS framework by using a codemod tool npx @next/codemod@canary upgrade 15.5.5.

Requested codemod wizard to use Turbopack configuration and to keep React v18. Also requested the suggested ESLint upgrade. Ran all the suggested codemods.

Ran the same codemod tool in project root, in app roots and in the packages/components.

NOTE: There seems to be a bug in the codemod wizard, since when it asks about upgrading the React, it updates the package version anyway, no matter what is chosen. So, those changes needed to be manually reverted.


Step 2:

Remove changes added by codemod since they are not working

Start supporting Turbopack in configuration level. There seems to be still some issues e.g. in stylesheet imports that makes the turbopack not usable. Also, we should separate the server side functiosn from clietn side functiosn much more stricter, which would be a huge job at this point. However, since it's preferred, the configuration is now added for future testing, but it's just not set as default.

@nikomakela nikomakela force-pushed the LIIKUNTA-768-upgrade-nextjs branch 3 times, most recently from 873af0b to a93b43a Compare November 25, 2025 07:45
@nikomakela nikomakela marked this pull request as ready for review November 25, 2025 08:43
@nikomakela

Copy link
Copy Markdown
Contributor Author

Comment thread next.base.config.mjs Outdated
/**
* Determine if Turbopack is active (i.e., next dev --turbo)
*/
const isTurbopack = process.env.NEXT_RUNTIME === 'edge' && isDevelopment;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to detect Turbopack, it looks like process.env.TURBOPACK works for that. I tried adding debug console logs after this:

  console.log('DEBUG:', {
    NEXT_RUNTIME: process.env.NEXT_RUNTIME,
    TURBOPACK: process.env.TURBOPACK,
    isDevelopment,
    isTurbopack,
  });

And the output in apps/sports-helsinki/ were with the above:

With --turbo:

$ yarn next dev --turbo
notice- Sourcemaps generation have been disabled through NEXT_DISABLE_SOURCEMAPS
DEBUG: {
  NEXT_RUNTIME: 'nodejs',
  TURBOPACK: '1',
  isDevelopment: true,
  isTurbopack: false
}

And without --turbo:

$ yarn next dev
notice- Sourcemaps generation have been disabled through NEXT_DISABLE_SOURCEMAPS
DEBUG: {
  NEXT_RUNTIME: 'nodejs',
  TURBOPACK: undefined,
  isDevelopment: true,
  isTurbopack: false
}

So --turbo → process.env.TURBOPACK = '1', no --turbo → process.env.TURBOPACK === undefined

@karisal-anders karisal-anders left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turbopack detection doesn't seem to work, otherwise ok. Didn't test except "yarn g:lint-fix && yarn g:typecheck && yarn g:teset --silent" in root and they worked.

@nikomakela nikomakela force-pushed the LIIKUNTA-768-upgrade-nextjs branch from a93b43a to 3dc928c Compare November 26, 2025 07:43
@nikomakela nikomakela force-pushed the LIIKUNTA-768-upgrade-nextjs branch from 3dc928c to 29a6ae0 Compare November 26, 2025 10:13
Base automatically changed from HCRC-178-hds-v4 to main November 26, 2025 12:45
LIIKUNTA-768.

Upgrade using NextJS v15 with React 18 (by using codemod tools).

It should be noted that this is not a well supported or adviced
combination by NextJS. There is no clear statement for supporting it --
only opposite.

See more:
1. A blog post that suggests that there should be no issues:
https://nextjs.org/blog/next-15#pages-router-on-react-18.
2. An official documentation and migration guide, that clearly states
that React v19 should be used:
https://nextjs.org/docs/15/app/guides/upgrading/version-15#react-19.
3. 3rd party blog that says it's okay to use React v18 with Pages
router:
https://www.wisp.blog/blog/can-nextjs-15-app-router-be-used-with-react-18.
4. Yet another page in docs that states that it's okay to use React v18,
even with NextJS v16: https://nextjs.org/docs/messages/react-version.

NOTE: The codemod fails when it was ran. No matter what is chosen for
React v18, it is still upgraded. Similar experiments here:
https://www.reddit.com/r/nextjs/comments/1gpb104/comment/lxw60lj/.

----

Step 1:

Upgrade the NextJS framework by using a codemod tool `npx
@next/codemod@canary upgrade 15.5.5`.

Requested codemod wizard to use Turbopack configuration and to keep
React v18. Also requested the suggested ESLint upgrade.  Ran all the
suggested codemods.

Ran the same codemod tool in project root, in app roots and in the
packages/components.

NOTE: There seems to be a bug in the codemod wizard, since when it asks
about upgrading the React, it updates the package version anyway, no
matter what is chosen. So, those changes needed to be manually reverted.

----

Step 2:

Remove changes added by codemod since they are not working

Start supporting Turbopack in configuration level. There seems to be
still some issues e.g. in stylesheet imports that makes the turbopack
not usable. Also, we should separate the server side functiosn from
clietn side functiosn much more stricter, which would be a huge job at
this point. However, since it's preferred, the configuration is now
added for future testing, but it's just not set as default.
@nikomakela nikomakela force-pushed the LIIKUNTA-768-upgrade-nextjs branch from 29a6ae0 to 09d1b39 Compare November 26, 2025 12:46
@nikomakela nikomakela merged commit dad7a98 into main Nov 26, 2025
11 of 12 checks passed
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@terovirtanen

Copy link
Copy Markdown
Contributor

FEDERATION-ROUTER branch is deployed to platta: https://events-graphql-federation-hobbies-pr923.dev.hel.ninja 🚀🚀🚀

@terovirtanen

Copy link
Copy Markdown
Contributor

FEDERATION-ROUTER branch is deployed to platta: https://events-graphql-federation-sports-pr923.dev.hel.ninja 🚀🚀🚀

@terovirtanen

Copy link
Copy Markdown
Contributor

FEDERATION-ROUTER branch is deployed to platta: https://events-graphql-federation-events-pr923.dev.hel.ninja 🚀🚀🚀

@sonarqubecloud

Copy link
Copy Markdown

@terovirtanen

Copy link
Copy Markdown
Contributor

TAPAHTUMAT-UI branch is deployed to platta: https://tapahtumat-pr923.dev.hel.ninja 🚀🚀🚀

@terovirtanen

Copy link
Copy Markdown
Contributor

EVENTS-GRAPHQL-PROXY branch is deployed to platta: https://events-graphql-proxy-pr923.dev.hel.ninja 🚀🚀🚀

@terovirtanen

Copy link
Copy Markdown
Contributor

HARRASTUKSET-UI branch is deployed to platta: https://harrastukset-pr923.dev.hel.ninja 🚀🚀🚀

@terovirtanen

Copy link
Copy Markdown
Contributor

LIIKUNTA-UI branch is deployed to platta: https://liikunta-pr923.dev.hel.ninja 🚀🚀🚀

@terovirtanen

Copy link
Copy Markdown
Contributor

TestCafe result is failed for https://tapahtumat-pr923.dev.hel.ninja 😿💢💥💥

@terovirtanen

Copy link
Copy Markdown
Contributor

TestCafe result is failed for https://harrastukset-pr923.dev.hel.ninja 😿💢💥💥

@terovirtanen

Copy link
Copy Markdown
Contributor

TestCafe result is failed for https://liikunta-pr923.dev.hel.ninja 😿💢💥💥

@charn charn deleted the LIIKUNTA-768-upgrade-nextjs branch July 8, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants