next.js: Upgrading to Next v15.0.0 throws a directly accessed param warning

Link to the code that reproduces this issue

https://github.com/auth0-developer-hub/web-app_nextjs_javascript_hello-world

To Reproduce

Download this project, https://github.com/auth0-developer-hub/web-app_nextjs_javascript_hello-world configure the local env on a free auth0 account or replace with next auth provider.

upgrade package with these dependencies

"@typescript-eslint/parser": "8.11.0",
"@auth0/nextjs-auth0": "3.5.0",
"axios": "1.7.7",
"eslint": "9.13.0",
"eslint-config-next": "15.0.0",
"next": "15.0.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"swr": "2.2.5"

run the project, attempt to login or directly access the /api/auth/login route (or appropriate auth route).

This will result in the following error.

Error:  In route /api/auth/[auth0] a param property was accessed directly with `params.auth0`. `params` should be awaited before accessing its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis

Current vs. Expected behavior

Current:

Error:  In route /api/auth/[auth0] a param property was accessed directly with `params.auth0`. `params` should be awaited before accessing its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis

Expected: Handle error, consider cases where the param is accessed directly.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #202405300957~1726766035~22.04~4092a0e SMP PREEMPT_DYNAMIC Thu S
  Available memory (MB): 15644
  Available CPU cores: 8
Binaries:
  Node: 20.17.0
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: 9.12.2
Relevant Packages:
  next: 15.0.0 // Latest available version is detected (15.0.0).
  eslint-config-next: 15.0.0
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.6.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Developer Experience, Pages Router

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

Reproduction URL

/api/auth/login

The issue

Next v15.0.0 now requires auth params to be awaited. Currently the handleAuth and handleLogin access the params directly, causing an error to be thrown by Next.

Similar issue logged and closed recently on next-auth repo.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 22 (8 by maintainers)

Most upvoted comments

import { use } from “react”;

export default function EditPost({ params }: { params: Promise<{ id: string }> }) { const { id } = use(params); return() } This solution works for me.

This is correct, it’s a bug with auth0 nextjs SDK, Kinde auth SDK had to be updated to support, they will have to do the same.

@Bahaa-Sobhy This is the expected behavior. 3rd party libraries will need to update. We adjusted how the warning is handled (the PR mentioned by Zack).

I recommend using the --help option if you’re not sure about a CLI tool (available on almost all CLI tools).

npx @next/codemod@latest --help

The above results in this:

Usage: @next/codemod [codemod] [source] [options]

Codemods for updating Next.js apps.

Arguments:
  codemod                       Codemod slug to run. See
                                "https://github.com/vercel/next.js/tree/canary/packages/next-codemod".
  source                        Path to source files or directory to transform including glob patterns.

Options:
  -v, --version                 Output the current version of @next/codemod.
  -f, --force                   Bypass Git safety checks and forcibly run codemods
  -d, --dry                     Dry run (no changes are made to files)
  -p, --print                   Print transformed files to stdout, useful for development
  --verbose                     Show more information about the transform process
  -j, --jscodeshift             (Advanced) Pass options directly to jscodeshift
  -h, --help                    Display this help message.

Commands:
  upgrade [options] [revision]  Upgrade Next.js apps to desired versions with a single command.

Here is the snippet you want if you want to update all your params for v15.

npx @next/codemod@latest next-async-request-api .

In the snippet, the <transform> is next-async-request-api. The . means you’re going to apply to every file in your directory. The documentation lists several different transforms for the respective upgrade scenarios.

this is not a bug, this is not temporary decision that NextJS gonna change in the future.

Yes, this is a permanent breaking change as of the v15 major release.

I saw now Codemods provided by your link 🙂, so, if we install it, we will not need to do changes to our code (no need to change the code to be awaitable params)

Yes, the Codemods were made to assist you in upgrading (so you don’t have to manually update each params).

@Bahaa-Sobhy We’ve built Codemods for these exact scenarios → https://nextjs.org/docs/app/building-your-application/upgrading/codemods#next-async-request-api (e.g., upgrading to async params).

We’re also working/assisting with 3rd-party libraries to update to these breaking changes! To clarify, this is not something new in the OSS space. Another example of breaking changes which required dependent packages to update is ESLint v8 to v9.

@samcx do you mean it’s a fault of 3rd party libraries? can you name them so we can se if we could get substitutions.

@DanielRivers

So should we adopt this solution as the official and permanent way to use params?


import { use } from "react";

export default function EditPost({ params }: { params: Promise<{ id: string }> }) {
const { id } = use(params);
return(// some codes ...)
}

As you guys know, params is being used in hundreds of files and components, if once adopted this code and updated all these files, it will be hard to again update and make different changes.

also a note - if I understood correctly - and if it’s the documented way to use params in Next 15.x i wonder how would people upgrade old apps from 13.x and 14.x ? these apps will broke for this change!?

@Bahaa-Sobhy As @samcx said, this is not something for next.js to fix