Skip to content

withPayload unconditionally injects webpack config — breaks Next.js 16 default Turbopack setup #14354

@a95z

Description

@a95z

Describe the Bug

After upgrading to Next.js 16, Payload projects using @payloadcms/next fail to start under the default Turbopack bundler.

Next.js now throws this error:

⨯ ERROR: This build is using Turbopack, with a webpack config and no turbopack config.
This may be a mistake.

This happens because withPayload always adds a webpack() hook to the Next.js config, even if the app is running in Turbopack mode.

When running with:

pnpm next dev --webpack

everything works fine, confirming it’s related to the injected webpack hook.

Expected: Payload should work with Next.js 16 defaults (Turbopack) without requiring the --webpack flag.

Link to the code that reproduces this issue

https://github.com/a95z/payload-next16-turbopack-bug/blob/main/package.json

Reproduction Steps

  1. Create a new Payload app:

     pnpm dlx create-payload-app@latest -t blank payload-next16-test
     cd payload-next16-test
  2. Upgrade Next.js:

    pnpm add next@16
  3. Run dev server

    pnpm next dev

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

area: core

Environment Info

Binaries:
  Node: 22.14.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  payload: 3.61.1
  next: 16.0.0
  @payloadcms/db-postgres: 3.61.1
  @payloadcms/drizzle: 3.61.1
  @payloadcms/email-nodemailer: 3.61.1
  @payloadcms/graphql: 3.61.1
  @payloadcms/next/utilities: 3.61.1
  @payloadcms/payload-cloud: 3.61.1
  @payloadcms/richtext-lexical: 3.61.1
  @payloadcms/translations: 3.61.1
  @payloadcms/ui/shared: 3.61.1
  react: 19.2.0
  react-dom: 19.2.0
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
  Available memory (MB): 16293
  Available CPU cores: 4

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions