Payload is an open-source, TypeScript-first headless CMS and application framework built on Node.js and React, frequently integrated with Next.js for full-stack applications. It is currently at version 3.83.0 and maintains an active release cadence, with multiple minor versions and bug fixes published monthly, indicating continuous and rapid development. A key differentiator is its code-first configuration approach, allowing developers to define collections, globals, and other configurations programmatically using TypeScript. This facilitates strong version control, type safety, and a developer-centric workflow, distinguishing it from CMS platforms that primarily rely on UI-driven configuration. Payload also provides a robust GraphQL API out-of-the-box, flexible authentication mechanisms, and a customizable, self-hosted admin panel, making it suitable for both content management and complex application backends.
npm install payloadVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates a minimal Payload configuration with two collections (Users and Posts), including authentication, basic fields, and relationship fields. It shows the `buildConfig` utility and how to define schemas. It also outlines the typical server initialization process.
Refer to the official Payload v2 to v3 migration guide on the Payload CMS website. This will involve deleting `admin.bundler` from your config, uninstalling old bundler packages, and updating custom UI components. Data migration scripts may also need careful review and adjustment.
Adjust your application logic to ensure client-side code does not directly rely on `PAYLOAD_PUBLIC_` prefixed variables. Pass necessary public configuration through props to client components or utilize server components where appropriate.
Always pin exact versions for all Payload-related packages in your `package.json` (e.g., `"payload": "3.83.0"` instead of `"^3.83.0"`). Delete `node_modules`, `package-lock.json` (or equivalent lock file), `.payload/`, and `.next/` directories, then run `npm install` (or `pnpm install`) to force a clean, consistent dependency resolution and rebuild.
Ensure your build environment has access to a database connection, or configure your Payload application to defer database connection until runtime, if possible. Monitor GitHub issues related to 'Build Fails Due to Missing Database Connection' for official fixes or workarounds.
Ensure all `payload` and `@payloadcms/*` packages, along with `react`, `react-dom`, and `next`, are pinned to identical versions in your `package.json`. Remove `node_modules`, `package-lock.json`, `.payload`, and `.next` directories, then reinstall dependencies.
Verify your `MONGODB_URI` in `.env` is correct and properly formatted. Ensure special characters in passwords are URI-encoded. Check network access, firewall rules, and if your database server is active and accessible. Consider using a tool like MongoDB Compass to test the connection independently.
Review your Payload configuration for `CORS`, `CSRF`, and `cookie` settings. Explicitly whitelist your frontend domain in `CORS` rather than using `*`. Check browser developer tools for cookie rejection warnings to diagnose misconfigured cookie domain or security flags. Verify your access control functions are correctly implemented.
Explicitly list allowed origins in your `cors` array (e.g., `cors: ['http://localhost:3000', 'http://localhost:8080']`). Ensure your `serverURL` in `payload.config.ts` accurately reflects the URL where your Payload API is accessible. For specific HTTP methods, ensure they are correctly cased (e.g., 'PATCH' not 'patch').