Keystatic Documentation
repository·main·Indexed 24 days ago
https://github.com/thinkmill/keystaticA file-based CMS with a TypeScript API that allows developers to manage content using Markdown and YAML/JSON without a database. Designed for integration with Next.js, Remix, and Astro, Keystatic connects directly to GitHub. The documentation covers project bootstrapping via @keystatic/create, configuration using the config() function, and the KeystarUI open-source component library.
What's inside Keystatic
- Keystatic Localization is an application designed to provide a user interface for managing localization (l10n) data for Keystatic projects. It allows non-technical contributors or those preferring a CMS-like experience to manage content and data that is otherwise stored in code-based formats like Markdown, JSON, or YAML.
Overview of Keystar UI Primitives
mainKeystar UI Primitives provides the foundational typography, sizing, and color tokens for the Keystar design system.
Note for Developers: The system is currently in development. It is acceptable to copy/paste tokens and manually adjust them as needed while the automation and validation workflows (such as Zod validation and Storybook previews) are being implemented.
What is Keystatic?
mainKeystatic is a first-class CMS experience designed for modern front-end frameworks like Next.js, Remix, and Astro. It provides a TypeScript API and uses Markdown and YAML/JSON as data formats without requiring a database. It connects directly to GitHub and is designed to work with your existing source code without modifying it.Overview of KeystarUI
mainKeystarUI is an open-source component library created by Thinkmill. It is designed to facilitate the building of high-quality interfaces, specifically for use with Keystatic and KeystoneJS.Create custom content components
mainYou can extend the Keystatic editor by defining custom components for
documentfields or specialized content types like MDX/Markdoc. Components can be:block: A structural component that wraps content.inline: A component that lives within a line of text.mark: A component used for text highlighting/styling.
Components use a
schemato define their own editable properties and apreviewfunction to render how the component looks in the editor.const components = { Highlight: mark({ label: 'Highlight', icon: highlighterIcon, schema: { variant: fields.select({ label: 'Variant', options: [ { label: 'Fluro', value: 'fluro' }, { label: 'Minimal', value: 'minimal' }, { label: 'Brutalist', value: 'brutalist' }, ], defaultValue: 'fluro', }), }, }), };Core design principles of KeystarUI
mainKeystarUI components are built around four core values:
- Accessible: Components are fully compatible with screen readers and support keyboard navigation.
- Responsive: Components support mouse, touch, and keyboard interactions and use responsive design to work across all devices.
- Adaptive: Components support both light and dark color schemes and can automatically adjust to the user's system settings.
- Inclusive: Components are engineered for a global audience, supporting features like right-to-left (RTL) language display and localized date and number formatting.
Understand Keystatic project templates
mainKeystatic provides two types of templates through the CLI:
- Simple templates: Basic implementations with minimal dependencies, stored within the main monorepo.
- Complex templates: Advanced examples stored in separate repositories to manage dependencies and assets efficiently.
All templates are published to npm and are downloaded by the CLI during the setup process. The CLI ensures that the template major version matches the CLI major version to prevent using out-of-date or incompatible cached versions.
Understand the Keystar design system token structure
mainThe design system is organized into collections that support multiple modes (e.g., light and dark themes).
Current Collections
- color: Includes scales, aliases, backgrounds, foregrounds, icons, and shadows. Supports
lightanddarkmodes. - size: Includes scales, borders, containers, dialogs, elements, icons, and radius/spacing.
Token Composition
Instead of using arbitrary t-shirt sizes for typography, the system aims to use semantic names (e.g.,
caption) that compose multiple properties into a single variant:colorfontFamilyfontSizefontWeightlineHeighttextTransform
- color: Includes scales, aliases, backgrounds, foregrounds, icons, and shadows. Supports
Deploy a Keystatic Remix app manually (DIY)
mainThe built-in Remix app server is production-ready for Node.js environments. When deploying manually, ensure you include the output generated by
remix build:build/public/build/
Develop a Keystatic Remix app
mainTo start the development server and enable hot-reloading (rebuilding assets on file changes), run the following command from your terminal:
npm run devKeystatic system requirements
mainTo run Keystatic or its development projects, ensure your environment meets the following requirements:
- Node.js: v18 or higher
- Package Manager:
pnpm
If you encounter issues with
pnpm, it is recommended to usecorepack. You can enable it by running:corepack enable pnpmRun the Next.js development server
mainTo start the development server for this project, use your preferred package manager to run the
devscript. Once running, the application will be available athttp://localhost:3000.npm run dev # or yarn dev # or pnpm dev # or bun dev