payload
Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
Top Related Projects
π Strapi is the leading open-source headless CMS. Itβs 100% JavaScript/TypeScript, fully customizable, and developer-first.
The flexible backend for all your projects π° Turn your DB into a headless CMS, admin panels, or apps with a custom UI, instant APIs, auth & more.
The superpowered headless CMS for Node.js β built with GraphQL and React
Sanity Studio β Rapidly configure content workspaces powered by structured content
Independent technology for modern publishing, memberships, subscriptions and newsletters.
A Git-based CMS for Static Site Generators
Quick Overview
Payload CMS is a self-hosted, headless content management system and application framework built with Node.js, Express, and React. It provides a powerful and flexible solution for managing content, with features like authentication, file uploads, and a customizable admin panel.
Pros
- Fully self-hosted and open-source, giving you complete control over your data and infrastructure
- Highly customizable with a plugin system and extensible admin UI
- Built-in TypeScript support for improved developer experience and type safety
- Includes features like authentication, file uploads, and versioning out of the box
Cons
- Steeper learning curve compared to some traditional CMS solutions
- Requires more setup and maintenance as a self-hosted solution
- Limited ecosystem of pre-built themes and plugins compared to more established CMS platforms
- May require more development resources for complex customizations
Code Examples
- Defining a collection:
import { CollectionConfig } from 'payload/types';
const Posts: CollectionConfig = {
slug: 'posts',
fields: [
{
name: 'title',
type: 'text',
required: true,
},
{
name: 'content',
type: 'richText',
},
],
};
export default Posts;
- Creating a custom field:
import { Field } from 'payload/types';
const CustomField: Field = {
name: 'customField',
type: 'text',
admin: {
components: {
Field: ({ field, value, onChange }) => {
return (
<input
type="text"
value={value}
onChange={(e) => onChange(e.target.value)}
/>
);
},
},
},
};
- Implementing access control:
import { Access } from 'payload/types';
const isAdminOrEditor: Access = ({ req: { user } }) => {
if (user) {
return {
or: [
{
'role': {
equals: 'admin',
},
},
{
'role': {
equals: 'editor',
},
},
],
};
}
return false;
};
Getting Started
- Install Payload:
npm install payload
- Create a new Payload project:
npx create-payload-app
- Start the development server:
npm run dev
- Access the admin panel at
http://localhost:3000/admin
and start building your content structure and API.
Competitor Comparisons
π Strapi is the leading open-source headless CMS. Itβs 100% JavaScript/TypeScript, fully customizable, and developer-first.
Pros of Strapi
- More mature and established project with a larger community and ecosystem
- Offers a user-friendly admin panel out-of-the-box
- Provides a marketplace for plugins and extensions
Cons of Strapi
- Can be resource-intensive and slower for large-scale applications
- Less flexible for custom backend logic and complex data relationships
- Steeper learning curve for developers new to the Strapi ecosystem
Code Comparison
Strapi (Content-Type definition):
module.exports = {
attributes: {
title: {
type: 'string',
required: true,
},
content: {
type: 'richtext',
},
},
};
Payload (Collection configuration):
export const Posts = {
slug: 'posts',
fields: [
{
name: 'title',
type: 'text',
required: true,
},
{
name: 'content',
type: 'richText',
},
],
};
Both Strapi and Payload are headless CMS solutions, but they differ in their approach and target audience. Strapi focuses on providing a complete out-of-the-box solution with a user-friendly interface, while Payload emphasizes flexibility and developer experience. The code comparison shows similarities in defining content structures, but Payload's approach is more JavaScript-native and TypeScript-friendly.
The flexible backend for all your projects π° Turn your DB into a headless CMS, admin panels, or apps with a custom UI, instant APIs, auth & more.
Pros of Directus
- More mature and established project with a larger community
- Offers a wider range of features out-of-the-box, including user management and file handling
- Provides a polished, user-friendly admin interface
Cons of Directus
- Can be more complex to set up and customize due to its extensive feature set
- May have a steeper learning curve for developers new to the system
- Potentially higher resource usage due to its comprehensive nature
Code Comparison
Directus configuration example:
module.exports = {
database: {
client: 'pg',
connection: {
host: '127.0.0.1',
port: 5432,
database: 'directus',
user: 'directus',
password: 'directus'
}
}
};
Payload configuration example:
export default {
collections: [
{
slug: 'posts',
fields: [
{
name: 'title',
type: 'text',
required: true,
},
],
},
],
};
Both Directus and Payload are headless CMS solutions, but they cater to different needs. Directus offers a more comprehensive set of features and a polished admin interface, making it suitable for larger projects with diverse requirements. Payload, on the other hand, provides a more lightweight and flexible approach, allowing for easier customization and integration into existing Node.js applications.
The superpowered headless CMS for Node.js β built with GraphQL and React
Pros of Keystone
- More mature and established project with a larger community and ecosystem
- Offers a wider range of built-in features and integrations out of the box
- Provides a powerful GraphQL API with automatic CRUD operations
Cons of Keystone
- Steeper learning curve due to its extensive feature set
- Can be more resource-intensive and slower for smaller projects
- Less flexibility in customizing the admin UI compared to Payload
Code Comparison
Keystone schema definition:
const User = list({
fields: {
name: text({ isRequired: true }),
email: text({ isRequired: true, isUnique: true }),
password: password(),
},
});
Payload schema definition:
const User = {
slug: 'users',
fields: [
{ name: 'name', type: 'text', required: true },
{ name: 'email', type: 'email', required: true, unique: true },
{ name: 'password', type: 'password' },
],
};
Both Keystone and Payload offer similar approaches to defining schemas, with Keystone using a more object-oriented style and Payload using a more declarative structure. Keystone's schema definition is slightly more concise, while Payload's is more explicit in its field types and options.
Sanity Studio β Rapidly configure content workspaces powered by structured content
Pros of Sanity
- More mature and established project with a larger community and ecosystem
- Offers a hosted solution, reducing infrastructure management overhead
- Provides a powerful query language (GROQ) for flexible content retrieval
Cons of Sanity
- Pricing can be expensive for larger projects or high-traffic applications
- Less control over the backend infrastructure due to its hosted nature
- Steeper learning curve for developers new to its concepts and query language
Code Comparison
Sanity schema definition:
export default {
name: 'post',
title: 'Post',
type: 'document',
fields: [
{
name: 'title',
title: 'Title',
type: 'string',
},
// ... other fields
],
}
Payload collection definition:
const Post = {
slug: 'posts',
fields: [
{
name: 'title',
type: 'text',
required: true,
},
// ... other fields
],
}
Both Sanity and Payload offer flexible content modeling, but Sanity's schema definition is more verbose and includes additional metadata. Payload's collection definition is more concise and straightforward, focusing on essential field properties.
While Sanity provides a powerful hosted solution with advanced querying capabilities, Payload offers more control over the backend and a simpler learning curve. The choice between the two depends on specific project requirements, scalability needs, and developer preferences.
Independent technology for modern publishing, memberships, subscriptions and newsletters.
Pros of Ghost
- More mature and established project with a larger community and ecosystem
- Offers a complete, ready-to-use blogging platform out of the box
- Includes built-in SEO tools and integrations with popular services
Cons of Ghost
- Less flexible for custom content types and data structures
- Steeper learning curve for developers wanting to extend or customize the core functionality
- Heavier and more opinionated, which may not suit all project requirements
Code Comparison
Ghost (Theme development):
{{#post}}
<article>
<h1>{{title}}</h1>
<div class="content">
{{content}}
</div>
</article>
{{/post}}
Payload (API usage):
const response = await payload.find({
collection: 'posts',
where: {
status: 'published',
},
limit: 10,
});
Ghost is a full-featured blogging platform, while Payload is a headless CMS that provides more flexibility for custom content structures. Ghost excels in providing a complete solution for bloggers and publishers, whereas Payload offers greater customization options for developers building complex content-driven applications. The choice between the two depends on the specific needs of the project and the desired level of control over the content management system.
A Git-based CMS for Static Site Generators
Pros of Decap CMS
- User-friendly interface for non-technical content editors
- Supports a wide range of static site generators
- Easy integration with existing static sites
Cons of Decap CMS
- Limited customization options for complex data structures
- Requires external authentication providers for user management
- Less suitable for dynamic content or complex applications
Code Comparison
Decap CMS (configuration):
backend:
name: git-gateway
branch: main
collections:
- name: "blog"
label: "Blog"
folder: "content/blog"
create: true
fields:
- {label: "Title", name: "title", widget: "string"}
- {label: "Body", name: "body", widget: "markdown"}
Payload CMS (configuration):
const Blog = {
slug: 'blog',
fields: [
{
name: 'title',
type: 'text',
required: true,
},
{
name: 'content',
type: 'richText',
},
],
};
export default Blog;
Decap CMS focuses on simplicity and ease of use for static site content management, while Payload offers more flexibility and power for building complex, dynamic applications. Decap CMS is ideal for small to medium-sized static sites, whereas Payload is better suited for larger, more complex projects requiring custom functionality and advanced data modeling.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Explore the DocsΒ ΓΒ·Β Community HelpΒ ΓΒ·Β RoadmapΒ ΓΒ·Β View G2 Reviews
[!IMPORTANT] Γ°ΒΒΒ We've released 3.0! Star this repo or keep an eye on it to follow along.
Payload is the first-ever Next.js native CMS that can install directly in your existing /app
folder. It's the start of a new era for headless CMS.
Benefits over a regular CMS
- Deploy anywhere, including serverless on Vercel for free
- Combine your front+backend in the same
/app
folder if you want - Don't sign up for yet another SaaS - Payload is open source
- Query your database in React Server Components
- Both admin and backend are 100% extensible
- No vendor lock-in
- Never touch ancient WP code again
- Build faster, never hit a roadblock
Quickstart
Before beginning to work with Payload, make sure you have all of the required software.
pnpx create-payload-app@latest
If you're new to Payload, you should start with the website template (pnpx create-payload-app@latest -t website
). It shows how to do everything - including custom Rich Text blocks, on-demand revalidation, live preview, and more. It comes with a frontend built with Tailwind all in one /app
folder.
One-click templates
Jumpstart your next project by starting with a pre-made template. These are production-ready, end-to-end solutions designed to get you to market as fast as possible.
Γ°ΒΒΒ Website
Build any kind of website, blog, or portfolio from small to enterprise. Comes with a fully functional front-end built with RSCs and Tailwind.
We're constantly adding more templates to our Templates Directory. If you maintain your own template, consider adding the payload-template
topic to your GitHub repository for others to find.
Γ’ΒΒ¨ Features
- Completely free and open-source
- Next.js native, built to run inside your
/app
folder - Use server components to extend Payload UI
- Query your database directly in server components, no need for REST / GraphQL
- Fully TypeScript with automatic types for your data
- Auth out of the box
- Versions and drafts
- Localization
- Block-based layout builder
- Customizable React admin
- Lexical rich text editor
- Conditional field logic
- Extremely granular Access Control
- Document and field-level hooks for every action Payload provides
- Intensely fast API
- Highly secure thanks to HTTP-only cookies, CSRF protection, and more
Γ°ΒΒΒΓ―ΒΈΒ Documentation
Check out the Payload website to find in-depth documentation for everything that Payload offers.
Migrating from v2 to v3? Check out the 3.0 Migration Guide on how to do it.
Γ°ΒΒΒ Contributing
If you want to add contributions to this repository, please follow the instructions in contributing.md.
Γ°ΒΒΒ Examples
The Examples Directory is a great resource for learning how to setup Payload in a variety of different ways, but you can also find great examples in our blog and throughout our social media.
If you'd like to run the examples, you can either copy them to a folder outside this repo or run them directly by (1) navigating to the example's subfolder (cd examples/your-example-folder
) and (2) using the --ignore-workspace
flag to bypass workspace restrictions (e.g., pnpm --ignore-workspace install
or pnpm --ignore-workspace dev
).
You can see more examples at:
Γ°ΒΒΒ Plugins
Payload is highly extensible and allows you to install or distribute plugins that add or remove functionality. There are both officially-supported and community-supported plugins available. If you maintain your own plugin, consider adding the payload-plugin
topic to your GitHub repository for others to find.
Γ°ΒΒΒ¨ Need help?
There are lots of good conversations and resources in our Github Discussions board and our Discord Server. If you're struggling with something, chances are, someone's already solved what you're up against. :point_down:
Γ’ΒΒ Like what we're doing? Give us a star
Γ°ΒΒΒ Thanks to all our contributors
Top Related Projects
π Strapi is the leading open-source headless CMS. Itβs 100% JavaScript/TypeScript, fully customizable, and developer-first.
The flexible backend for all your projects π° Turn your DB into a headless CMS, admin panels, or apps with a custom UI, instant APIs, auth & more.
The superpowered headless CMS for Node.js β built with GraphQL and React
Sanity Studio β Rapidly configure content workspaces powered by structured content
Independent technology for modern publishing, memberships, subscriptions and newsletters.
A Git-based CMS for Static Site Generators
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot