keystone
The superpowered headless CMS for Node.js β built with GraphQL and React
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.
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.
Sanity Studio β Rapidly configure content workspaces powered by structured content
A Git-based CMS for Static Site Generators
Quick Overview
Keystone is a powerful and flexible headless CMS and application framework built with Node.js, GraphQL, and React. It provides a scalable and customizable solution for content management, allowing developers to create robust web applications and APIs with ease.
Pros
- Highly customizable and extensible architecture
- Built-in GraphQL API for efficient data querying and manipulation
- Powerful Admin UI for content management out of the box
- Supports various database backends, including MongoDB and PostgreSQL
Cons
- Steeper learning curve compared to some simpler CMS solutions
- Documentation can be overwhelming for beginners
- Limited themes and templates available for quick setup
Code Examples
- Defining a Keystone schema:
import { list } from '@keystone-6/core';
import { text, relationship } from '@keystone-6/core/fields';
export const lists = {
User: list({
fields: {
name: text({ validation: { isRequired: true } }),
email: text({ isUnique: true, validation: { isRequired: true } }),
posts: relationship({ ref: 'Post.author', many: true }),
},
}),
Post: list({
fields: {
title: text(),
content: text({ ui: { displayMode: 'textarea' } }),
author: relationship({ ref: 'User.posts' }),
},
}),
};
- Querying data using the GraphQL API:
query {
users {
name
email
posts {
title
}
}
}
- Customizing the Admin UI:
import { config } from '@keystone-6/core';
export default config({
ui: {
isAccessAllowed: (context) => !!context.session?.data,
},
// ... other configuration options
});
Getting Started
To get started with Keystone, follow these steps:
- Install Keystone:
npm init keystone-app my-app
- Navigate to the project directory:
cd my-app
- Start the development server:
npm run dev
-
Open your browser and visit
http://localhost:3000
to access the Admin UI. -
Begin defining your schema and customizing your application in the
schema.ts
file.
Competitor Comparisons
π Strapi is the leading open-source headless CMS. Itβs 100% JavaScript/TypeScript, fully customizable, and developer-first.
Pros of Strapi
- User-friendly admin panel with a visual content builder
- Extensive plugin ecosystem for easy customization
- Built-in authentication and user management system
Cons of Strapi
- Less flexible data modeling compared to Keystone
- Higher resource consumption, especially for larger projects
- Steeper learning curve for developers new to Node.js
Code Comparison
Strapi (Content-Type definition):
module.exports = {
attributes: {
title: {
type: 'string',
required: true,
},
content: {
type: 'richtext',
},
},
};
Keystone (Schema definition):
const { Text, Relationship } = require('@keystonejs/fields');
module.exports = {
fields: {
title: { type: Text, isRequired: true },
content: { type: Text, multiline: true },
},
};
Both Strapi and Keystone are powerful headless CMS solutions, but they cater to different needs. Strapi excels in providing a user-friendly interface and quick setup, making it ideal for content managers and smaller projects. Keystone, on the other hand, offers more flexibility in data modeling and is better suited for complex, custom applications. The code comparison shows that both systems use JavaScript for configuration, but Keystone's approach is more code-centric, while Strapi leans towards a more declarative style.
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
- User-friendly interface with a modern, intuitive design
- Supports multiple database types (MySQL, PostgreSQL, SQLite, etc.)
- Built-in REST and GraphQL APIs for easy integration
Cons of Directus
- Less flexible for custom backend logic compared to Keystone
- Steeper learning curve for developers familiar with Node.js frameworks
- Limited extensibility options compared to Keystone's plugin system
Code Comparison
Directus (REST API example):
const { Directus } = require('@directus/sdk');
const directus = new Directus('https://api.example.com');
const items = await directus.items('articles').readByQuery({
limit: 5,
sort: '-date_created'
});
Keystone (GraphQL API example):
const { gql } = require('@keystone-6/core');
const GET_ARTICLES = gql`
query {
articles(orderBy: { createdAt: desc }, first: 5) {
id
title
content
}
}
`;
const articles = await context.query.Article.findMany({
orderBy: { createdAt: 'desc' },
take: 5,
});
Both Directus and Keystone offer powerful headless CMS capabilities, but they cater to different developer preferences and project requirements. Directus excels in user-friendliness and database flexibility, while Keystone provides more control over backend logic and extensibility.
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.
Pros of Payload
- More flexible and customizable admin UI
- Better TypeScript support and type safety
- Simpler setup and configuration process
Cons of Payload
- Smaller community and ecosystem compared to Keystone
- Less mature and fewer out-of-the-box features
- Limited GraphQL support (primarily REST-focused)
Code Comparison
Keystone schema definition:
const User = list({
fields: {
name: text({ isRequired: true }),
email: text({ isRequired: true, isUnique: true }),
password: password(),
},
});
Payload collection definition:
const Users = {
slug: 'users',
fields: [
{
name: 'name',
type: 'text',
required: true,
},
{
name: 'email',
type: 'email',
required: true,
unique: true,
},
{
name: 'password',
type: 'text',
required: true,
},
],
};
Both Keystone and Payload are headless CMS platforms, but they have different approaches and strengths. Keystone offers a more established ecosystem and GraphQL-first approach, while Payload focuses on flexibility, TypeScript support, and a simpler setup process. The code comparison shows similarities in defining data models, but Payload's approach is more JSON-like, while Keystone uses a more declarative style.
Sanity Studio β Rapidly configure content workspaces powered by structured content
Pros of Sanity
- Real-time collaboration features for content editing
- Flexible content modeling with customizable schemas
- Powerful querying capabilities with GROQ (Graph-Relational Object Queries)
Cons of Sanity
- Steeper learning curve for developers new to the platform
- Less control over the underlying database structure
Code Comparison
Sanity schema definition:
export default {
name: 'author',
type: 'document',
fields: [
{
name: 'name',
type: 'string',
title: 'Name'
},
{
name: 'bio',
type: 'text',
title: 'Biography'
}
]
}
Keystone schema definition:
import { list } from '@keystone-6/core';
import { text } from '@keystone-6/core/fields';
export const lists = {
Author: list({
fields: {
name: text({ validation: { isRequired: true } }),
bio: text({ ui: { displayMode: 'textarea' } }),
},
}),
};
Both Sanity and Keystone offer powerful content management capabilities, but they differ in their approach. Sanity provides a more flexible content modeling system with its schema definitions, while Keystone offers a more traditional database-oriented structure. Sanity's real-time collaboration features make it attractive for teams working on content-heavy projects, while Keystone's integration with Node.js and GraphQL may be preferred by developers looking for a more customizable backend solution.
A Git-based CMS for Static Site Generators
Pros of Decap CMS
- Simpler setup and configuration, especially for static sites
- Better integration with popular static site generators like Gatsby and Hugo
- More user-friendly interface for content editors
Cons of Decap CMS
- Less flexible for complex data structures and relationships
- Limited customization options compared to Keystone's extensibility
- Fewer built-in features for user management and authentication
Code Comparison
Decap CMS configuration (in YAML):
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"}
Keystone schema definition:
const { Text, Relationship } = require('@keystonejs/fields');
module.exports = {
fields: {
title: { type: Text },
content: { type: Text, multiline: true },
author: { type: Relationship, ref: 'User' },
},
};
Both CMSs offer different approaches to content management. Decap CMS is more suited for simple static sites, while Keystone provides greater flexibility and power for complex applications.
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
Keystone helps you build faster and scale further than any other CMS or App Framework. Describe your schema, and get a powerful GraphQL API & beautiful Management UI for your content and data.
No boilerplate or bootstrapping Γ’ΒΒ just elegant APIs to help you ship the code that matters without sacrificing the flexibility or power of a bespoke back-end.
Contents
Usage & Documentation
Keystone 6 is published to npm under the @keystone-6/*
namespace.
You can find our extended documentation on our website, but some quick links that might be helpful:
- Read Why Keystone to learn about our vision and what's in the box.
- Getting Started walks you through first steps with the
create-keystone-app
CLI. - Our Examples contain a growing collection of projects you can run locally to learn more about a Keystone feature.
- An API Reference contains the details on Keystone's foundational building blocks.
- Some Guides offer practical walkthroughs on how to build with those blocks.
Γ°ΒΒΒ‘ While our
API Reference
is generally complete, we are are still working hard on increasing the fidelity of ourguides
andexamples
. If you have an example you'd like see, please open a GitHub discussion!
Our @keystone-6/*
packages are written for the Node Maintenance and Active LTS versions of Node; and our continuous integration seamlessly tracks that.
You may have success with Node versions that are Pending or End-of-Life, but you may have problems too.
Looking for Keystone 5?
The Keystone 5 codebase is now in maintenance mode and lives at keystonejs/keystone-5. For more information read Keystone 5 and beyond.
Enjoying Keystone?
- Star this repo Γ°ΒΒΒ Γ’ΒΒΓ―ΒΈΒ
- Follow Keystone on Twitter
- Join the conversation in Keystone community Slack.
Interested in what's new?
For a birds-eye view of what the Keystone project is working towards, check out our Roadmap.
Feedback
Share your thoughts and feature requests on Slack (preferred) or Twitter. Bugfixes and issues always welcome.
Versioning
Keystone follows semver.
Code of Conduct
Keystone adheres to the Contributor Covenant Code of Conduct.
Security
For vulnerability reporting, please refer to our security policy.
License
Copyright (c) 2024 Thinkmill Labs Pty Ltd. Licensed under the MIT License.
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.
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.
Sanity Studio β Rapidly configure content workspaces powered by structured content
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