# KeystoneJS — Superpowered Headless CMS for Node.js > A programmable headless CMS and application backend built with GraphQL, React, and TypeScript that lets you define schemas in code and auto-generates an Admin UI and API. ## Install Save as a script file and run: # KeystoneJS — Superpowered Headless CMS for Node.js ## Quick Use ```bash npm init keystone-app@latest my-app cd my-app npm run dev # Admin UI at http://localhost:3000 # GraphQL playground at http://localhost:3000/api/graphql ``` ## Introduction KeystoneJS is a headless CMS and application backend for Node.js. You define your data schema in TypeScript, and Keystone automatically generates a GraphQL API, a React-based Admin UI, and database migrations. It is designed for developers who want CMS capabilities with full programmatic control. ## What KeystoneJS Does - Generates a complete GraphQL API from TypeScript schema definitions - Auto-creates an Admin UI with list views, filters, and relationship management - Manages database migrations for PostgreSQL, MySQL, and SQLite via Prisma - Provides access control rules at the list, field, and operation level - Supports custom server-side logic through hooks, virtual fields, and custom mutations ## Architecture Overview Keystone is built on top of Prisma for database access and Apollo Server for the GraphQL layer. When you define lists and fields in your `keystone.ts` config file, Keystone generates Prisma schemas, GraphQL type definitions, and React Admin UI pages. The Admin UI is a Next.js application that communicates with the Keystone GraphQL endpoint. Hooks let you run custom logic before or after create, update, and delete operations. ## Self-Hosting & Configuration - Scaffold a project with `npm init keystone-app@latest` and choose your database - Define your data model in `keystone.ts` using the `list()` and field helpers - Set the `db.provider` to `postgresql`, `mysql`, or `sqlite` with a connection string - Configure authentication with the built-in `createAuth()` helper for password-based login - Deploy as a standard Node.js application to any hosting provider or container platform ## Key Features - Schema-as-code: define your entire data model in TypeScript with full IDE autocomplete - Relationship fields: polymorphic, one-to-many, and many-to-many relations with back-references - Document field: a structured rich-text editor with customizable block types and inline components - Access control: declarative rules that can reference the current session, item, or input data - Extensible Admin UI: add custom pages, branded views, or override default components ## Comparison with Similar Tools - **Strapi** — UI-first CMS with a visual schema builder; Keystone is code-first with TypeScript schema definitions - **Payload CMS** — code-first CMS with REST and GraphQL; Keystone is GraphQL-native and uses Prisma for the ORM - **Directus** — database-first CMS that wraps existing tables; Keystone generates and manages the schema from code - **Sanity** — hosted CMS with a custom query language; Keystone is self-hosted with standard GraphQL - **Hasura** — auto-generates GraphQL from Postgres; Keystone adds an Admin UI, hooks, and schema authoring ## FAQ **Q: Which databases does Keystone support?** A: PostgreSQL, MySQL, and SQLite through Prisma. PostgreSQL is recommended for production. **Q: Can I add custom GraphQL mutations and queries?** A: Yes. Use the `extendGraphqlSchema` config option to add custom resolvers, types, and mutations alongside the auto-generated ones. **Q: Does Keystone handle authentication?** A: Keystone provides a `createAuth()` helper for password-based authentication with session management. For OAuth or SSO, you can integrate third-party libraries. **Q: Is Keystone suitable for large applications?** A: Yes. Keystone is designed as an application backend, not just a content editor. Access control, hooks, and custom logic support complex business requirements. ## Sources - https://github.com/keystonejs/keystone - https://keystonejs.com/docs --- Source: https://tokrepo.com/en/workflows/asset-ea6c702a Author: Script Depot