Skip to content

Config returns null in production build (Next.js 16 + Turbopack RSC) #15429

Open

Description

@TheGenXCoder

Describe the Bug

PayloadCMS Config Returns null in Production Build (Next.js 16 + Turbopack)

Environment

  • PayloadCMS: 3.73.0 (latest, with Next.js 16 support)
    • Next.js: 16.2.0-canary.17 (meets >16.1.1-canary.35 OR 16.2.0+ requirement)
      • React: 19.2.4
        • Runtime: Bun 1.3.8 (also reproduced with Node 22)
          • Database: PostgreSQL via @payloadcms/db-postgres
            • Bundler: Turbopack (Next.js 16 default)
              • Build Target: Docker production build

Summary

When running PayloadCMS in a Next.js 16 production build with Turbopack, the Payload config object returns null when imported in React Server Component context, specifically in the (payload)/layout.tsx file. This causes the admin panel to fail with an RSC error.

Error occurs ONLY:

Link to the code that reproduces this issue

N/A (Reproduction steps provided below)N/A (Reproduction steps provided below)

Reproduction Steps

See the 'Describe the Bug' section above for full reproduction details and code blocks.

Which area(s) are affected?

area: core

Environment Info

PayloadCMS: 3.73.0, Next.js: 16.2.0-canary.17, React: 19.2.4, Bun: 1.3.8, Bundler: Turbopack

Activity

  1. added
    status: needs-triage
    validate-reproduction
    on Jan 30, 2026
  2. added
    area: core
    and removed
    validate-reproduction
    on Jan 30, 2026
  3. github-actions commented on Jan 30, 2026

    @github-actions
    Contributor

    Please add a reproduction in order for us to be able to investigate.

    Depending on the quality of reproduction steps, this issue may be closed if no reproduction is provided.

    Why was this issue marked with the invalid-reproduction label?

    To be able to investigate, we need access to a reproduction to identify what triggered the issue. We prefer a link to a public GitHub repository created with create-payload-app@latest -t blank or a forked/branched version of this repository with tests added (more info in the reproduction-guide).

    To make sure the issue is resolved as quickly as possible, please make sure that the reproduction is as minimal as possible. This means that you should remove unnecessary code, files, and dependencies that do not contribute to the issue. Ensure your reproduction does not depend on secrets, 3rd party registries, private dependencies, or any other data that cannot be made public. Avoid a reproduction including a whole monorepo (unless relevant to the issue). The easier it is to reproduce the issue, the quicker we can help.

    Please test your reproduction against the latest version of Payload to make sure your issue has not already been fixed.

    I added a link, why was it still marked?

    Ensure the link is pointing to a codebase that is accessible (e.g. not a private repository). "example.com", "n/a", "will add later", etc. are not acceptable links -- we need to see a public codebase. See the above section for accepted links.

    Useful Resources

  4. removed
    status: needs-triage
    on Jan 30, 2026
  5. AlessioGr commented on Jan 30, 2026

    @AlessioGr
    Member

    Can you try if 16.2.0-canary.16 works?

  6. TheGenXCoder commented on Jan 30, 2026

    @TheGenXCoder
    Author

    Thanks for the quick response @AlessioGr!

    I tested 16.2.0-canary.16 as suggested, but encountered a different error during the build:

    Error: Failed to load external module @payloadcms/next-63b069c48ca83adb/layouts: 
    TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".css" for 
    /app/node_modules/react-image-crop/dist/ReactCrop.css
    

    This appears to be a Turbopack issue with CSS imports in externalized packages. The build gets further than with .17 (which had the config null runtime error), but now fails during page data collection when trying to import CSS from react-image-crop.

    With 16.2.0-canary.17: Config returns null at runtime (original issue)
    With 16.2.0-canary.16: Build fails with CSS import error

    Should I try an even earlier canary, or is there a different approach for PayloadCMS + Turbopack production builds?

  7. TheGenXCoder commented on Jan 30, 2026

    @TheGenXCoder
    Author

    Update: Webpack testing confirms issue is NOT bundler-specific

    I tested forcing webpack instead of Turbopack to isolate the problem:

    Configuration:

    // next.config.mjs
    experimental: {
      turbo: false, // Force webpack
    }

    Results:

  8. TheGenXCoder commented on Jan 30, 2026

    @TheGenXCoder
    Author

    Supplementary Update: Full Webpack Testing Results

    It seems my previous comment was truncated. Here are the full findings from the webpack testing:

    Configuration used to force Webpack:

    // next.config.mjs
    const nextConfig = {
      output: 'standalone',
      typescript: {
        ignoreBuildErrors: true,
      },
      experimental: {
        turbo: false, // Disable Turbopack, use webpack
      },
    }

    Test Results:

    • ✅ Build Success: Webpack successfully compiled the production build and generated static pages in ~11s.
    • ❌ Runtime Failure: The admin interface still fails to load with a TypeError.

    Webpack Runtime Error:

    TypeError: Cannot destructure property 'admin' of 'q' as it is undefined.
    

    (Where 'q' is the minified config object).

    Conclusion:
    This confirms the issue is not bundler-specific. Both Turbopack and Webpack exhibit similar failures when loading the Payload configuration in a production RSC context with Next.js 16. This points towards a core incompatibility in how the configuration is being loaded/shared in this environment.

    Should I try downgrading to Next.js 15 to help isolate if this is a regression specific to Next.js 16? .

  9. TheGenXCoder commented on Jan 30, 2026

    @TheGenXCoder
    Author

    Next.js 15 Test Results

    Following up on my question about downgrading to Next.js 15 - I've tested with Next.js 15.1.6 (stable) and can confirm the issue persists with the exact same error:

    TypeError: Cannot destructure property 'admin' of 'H' as it is undefined.
        at dG (.next/server/app/(payload)/admin/[[...segments]]/page.js:9:136607)
    

    This confirms the issue is not a Next.js 16 regression but affects PayloadCMS production builds on both Next.js 15 and 16.

    Environment Details:

    • Next.js: 15.1.6 (stable)
      • PayloadCMS: 3.73.0
        • Bundler: Tested with both Webpack and Turbopack (same result)
          • Deployment: Kubernetes production environment

          • The route handlers are also failing with "No response is returned from route handler" errors because they encounter the config error and can't return a proper Response object.

          • Is there a known workaround or ETA on a fix? This is blocking production deployment.Next.js 15 Test Results
  10. AlessioGr commented on Feb 13, 2026

    @AlessioGr
    Member

    TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".css" for

    This is an error in your project - it means you're importing client code into your payload config somewhere which is not allowed, since the payload config has to be node-safe.

    As for Next.js 15.1.6, this version is not supported by Payload. Could you share a reproduction repo (https://github.com/payloadcms/payload/blob/main/ISSUE_GUIDE.md) for this problem using a supported Next.js version? I recommend either 15.4.11, or the latest Next.js 16.2.x canary

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

Metadata

Metadata

Assignees

Labels

area: coreinvalid-reproduction

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions