NextJS 15버전을 사용 시 아래와 같은 에러가 발생 하였다.
A param property was accessed directly with `params.id`. `params` is now a Promise and
should be unwrapped with `React.use()` before accessing properties of the underlying params object.
In this version of Next.js direct access to param properties is still supported to facilitate migration but in a future version you will be required to unwrap `params` with `React.use()`.
Error: Route "/community/posts/[id]" used `params.id`. `params` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
공식문서를 살펴보자.
$ npx @next/codemod@canary next-async-request-api .
위 명령어를 통해 자동으로 변경해준다고 고지되어있다.
$ npx @next/codemod@canary next-async-request-api .
Need to install the following packages:
@next/codemod@15.4.0-canary.38
Ok to proceed? (y) y
Thank you for using @next/codemod!
But before we continue, please stash or commit your git changes.
You may use the --force flag to override this safety check.
commit 하고 다시 해보자!
Processing 127 files...
Spawning 11 workers...
Sending 12 files to free worker...
Sending 12 files to free worker...
Sending 12 files to free worker...
Sending 12 files to free worker...
Sending 12 files to free worker...
Sending 12 files to free worker...
Sending 12 files to free worker...
Sending 12 files to free worker...
Sending 12 files to free worker...
Sending 12 files to free worker...
Sending 7 files to free worker...
All done.
Results:
0 errors
126 unmodified
0 skipped
1 ok
Time elapsed: 2.676seconds
정상적으로 해결되었고 에러도 뜨지 않았다!