#๐Ÿ†˜ Help Needed: Payload CMS 3.59 Admin Panel Not Loading - Config Undefined Error

3 messages ยท Page 1 of 1 (latest)

regal lark
#

Configuration

payload.config.ts (root):

// Re-export the Payload config from src
// This allows Next.js to import from '@payload-config'
export { default } from "./src/payload/payload.config";

src/payload/payload.config.ts:

import { buildConfig } from "payload";
import { mongooseAdapter } from "@payloadcms/db-mongodb";
import { lexicalEditor } from "@payloadcms/richtext-lexical";
import path from "path";
import sharp from "sharp";

// Collections
import { Providers } from "./collections/Providers";
import { Users } from "./collections/Users";
import { Media } from "./collections/Media";

export default buildConfig({
  admin: {
    user: Users.slug,
    meta: {
      titleSuffix: "- Finding Finance",
    },
  },
  collections: [Users, Providers, Media],
  db: mongooseAdapter({
    url: process.env.MONGODB_URI || "mongodb://localhost:27017/finding-finance",
  }),
  editor: lexicalEditor({}),
  typescript: {
    outputFile: path.resolve(__dirname, "payload-types.ts"),
  },
  secret: process.env.PAYLOAD_SECRET || "your-secret-key-change-in-production",
  sharp,
  cors: [
    process.env.NEXT_PUBLIC_SERVER_URL || "http://localhost:3000",
    "http://localhost:3000",
  ].filter(Boolean),
  csrf: [
    process.env.NEXT_PUBLIC_SERVER_URL || "http://localhost:3000",
    "http://localhost:3000",
  ].filter(Boolean),
});

next.config.ts:

import type { NextConfig } from "next";
import { withPayload } from "@payloadcms/next/withPayload";

const nextConfig: NextConfig = {
  /* config options here */
};

export default withPayload(nextConfig);

tsconfig.json paths:

"paths": {
  "@/*": ["./src/*"],
  "@payload-config": ["./payload.config.ts"]
}
#

What I've Checked
โœ… MongoDB is running and accessible (confirmed via docker ps and connection test)
โœ… Redis is running
โœ… TypeScript compiles without errors
โœ… No environment variables are missing (using default values)
โœ… The config file exports properly (confirmed via grep)
โœ… Collections are properly defined with required fields
โœ… withPayload() is wrapping the Next.js config

Questions

  1. Is there a known issue with Payload CMS 3.59 + Next.js 15.5 + React 19?
  2. Should the config import pattern be different for Next.js 15 App Router?
  3. Is there an async/await issue with how the config is being loaded?
  4. Could this be related to Turbopack? (running npm run dev uses --turbopack)

Additional Context

  • This is a fresh setup
  • No users exist in the database yet (first time setup)
  • The project uses App Router with route groups: src/app/(payload)/admin/[[...segments]]/page.tsx
  • Running in development mode with npm run dev

Has anyone encountered this issue or know how to properly configure Payload CMS 3.59 with Next.js 15.5? Any help would be greatly appreciated! ๐Ÿ™