Skip to content

fix(next): warn at startup when installed Next.js is outside supported peer range - #17137

Open
hemraj-007 wants to merge 1 commit into
payloadcms:mainfrom
hemraj-007:fix/next-unsupported-version-warning
Open

hemraj-007 wants to merge 1 commit into
payloadcms:mainfrom
hemraj-007:fix/next-unsupported-version-warning

Conversation

@hemraj-007

Copy link
Copy Markdown

What?

Adds a startup check in withPayload() that compares the installed Next.js
version against the next peer-dependency range declared by @payloadcms/next.
If the installed version falls outside that range, Payload logs a clear,
actionable warning. When the version is supported (or can't be determined), it
stays silent and never blocks the build.

New helpers in withPayload.utils.js:

  • getSupportedNextRange() — reads the declared peer range from the package's own package.json (stays in sync automatically).
  • satisfiesNextRange() — minimal semver range check (supports >= < and disjoint || ranges) with no runtime semver dependency, since this runs inside next.config before the build.
  • getUnsupportedNextVersionWarning() — pure builder for the warning message.

Example output:

Payload: the installed Next.js version (16.2.1) is outside the supported range ">=16.2.6 <17.0.0". Unsupported versions may break the Admin Panel or contain unpatched security advisories. Install a supported Next.js version to clear this warning.

Why?

Payload declares a next peer dependency but never enforced it at runtime.
Installing an unsupported version (e.g. in the 16.0.0–16.2.5 gap) produced a
cryptic "This page could not be found" admin failure with no hint that Next was
the cause. A one-line startup warning turns an opaque debugging session into an
obvious fix, and surfaces the security angle (the >=16.2.6 floor exists for
security reasons).

How?

withPayload() runs when next.config loads — the single hook that fires for
dev, build, and start — and already emits other startup warnings, so the
check lives there. The range is read from the package's own peerDependencies
so it never drifts from what's actually published.

Fixes #17119

…d peer range

Payload declares a `next` peer dependency but never enforced it at runtime,
so an unsupported version produced a cryptic admin failure. withPayload now
compares the resolved Next.js version against the declared peer range and logs
a clear, actionable warning at startup.

Closes payloadcms#17119

Co-authored-by: Cursor <[email protected]>
@github-actions github-actions Bot added the stale label Nov 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warn at startup when the installed Next.js version is outside Payload's supported peer range

1 participant