Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
In short, it makes params / headers return promises so you have to await them. Its meant to also allow the previous approach for backwards compatability temporarily. However, it seems like this is not working as intended and it breaking next build (production builds).
The errors stem from the api/payload folder.
Example build error from yarn build:
Linting and checking validity of types ...Failed to compile.
.next/types/app/(payload)/admin/[[...segments]]/page.ts:30:29
Type error: Type 'Args' does not satisfy the constraint 'PageProps'.
Types of property 'params' are incompatible.
Type '{ segments: string[]; }' is missing the following properties from type 'Promise<SegmentParams>': then, catch, finally, [Symbol.toStringTag]
28 |
29 | // Check the prop type of the entry function
> 30 | checkFields<Diff<PageProps, FirstArg<TEntry['default']>, 'default'>>()
| ^
31 |
32 | // Check the arguments and return type of the generateMetadata function
33 | if ('generateMetadata' in entry) {
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Example console errors during yarn dev:
In route /api/[...slug] a param property was accessed directly with `params.slug`. `params` is now a Promise and should be awaited 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 await `params`. If this use is inside an async function await it. If this use is inside a synchronous function then convert the function to async or await it from outside this function and pass the result in.
Reproduction Steps
Use any Payload project using payload3.0.0-beta.109 and nextjs15.0.0-canary.171.
Link to reproduction
No response
Environment Info
Describe the Bug
As of Next.js v15.0.0-canary.171, the following change was introduced: https://github.com/vercel/next.js/pull/68812
You can read more about the change here: https://github.com/vercel/next.js/pull/68812
In short, it makes params / headers return promises so you have to await them. Its meant to also allow the previous approach for backwards compatability temporarily. However, it seems like this is not working as intended and it breaking
next build
(production builds).The errors stem from the
api/payload
folder.Example build error from
yarn build
:Example console errors during
yarn dev
:Reproduction Steps
payload
3.0.0-beta.109
andnextjs
15.0.0-canary.171
.yarn dev
/api/
route.yarn build
Adapters and Plugins
No response