DEV Community

Arhan Khan
Arhan Khan

Posted on

KeystoneJS for Beginners: A CMS and GraphQL API You Build With Code

KeystoneJS is a headless CMS you define in code. Instead of clicking through an admin panel to create content types, you write a schema in TypeScript — lists, fields, relationships, and access rules — and Keystone generates both a GraphQL API and a beautiful admin UI from it. It is the CMS for developers who would rather write a schema than fill in forms.

How it works: you describe a list like Post with fields for title, content, and an author relationship. Keystone creates the database tables, the GraphQL queries and mutations, and the admin screens automatically. Access control is also code: a function decides who can read, create, or update each list, so rules like "only the author can edit a draft" live in one readable place.

Keystone is a good fit for beginners who already know some JavaScript because the schema reads like plain code, not configuration. You can see the entire shape of your content in one file, and changing it is just editing that file. The admin UI it generates is genuinely pleasant — your non-technical teammates get a real CMS while you keep full control of the data model.

A quick taste of a Keystone schema:

export const lists = {
  Post: list({
    fields: {
      title: text({ validation: { isRequired: true } }),
      content: text(),
      author: relationship({ ref: "User.posts", many: false }),
    },
  }),
};
Enter fullscreen mode Exit fullscreen mode

From that alone, Keystone builds the database table, the GraphQL API, and the admin editing screen for posts.

Who is it for? JavaScript and TypeScript developers building blogs, docs sites, and content-driven apps; teams that want a CMS whose content model lives in version control; students learning how a GraphQL API is actually built.

Limits to know: Keystone is code-first, so non-developers cannot create new content types without you. It runs on Node.js and needs a database, so it is heavier to host than a static site. And its community is smaller than WordPress or Strapi, so answers to rare problems take longer to find.

To start today: run the starter project, define one list with three fields, open the generated admin UI, and create your first item there.

Top comments (0)