Configuration

Every Keystatic project expects an exported config. The config() function can be imported from the @keystatic/core package:

// keystatic.config.ts
import { config } from '@keystatic/core'

export default config({
  // ...
})

Example

Here's an example of a Keystatic config that creates a posts collection, stored on the local file system within the src/content/posts directory.

Each post has a title as well as a long-form, WYSIWYG content field.

// keystatic.config.ts
import { config, fields, collection } from '@keystatic/core';

export default config({
  storage: {
    kind: 'local',
  },
  collections: {
    posts: collection({
      label: 'Posts',
      slugField: 'title',
      path: 'src/content/posts/*',
      format: { contentField: 'content' },
      schema: {
        title: fields.slug({ name: { label: 'Title' } }),
        content: fields.document({
          label: 'Content',
          formatting: true,
          dividers: true,
          links: true,
          images: true,
        }),
      },
    }),
  },
});

Options

Branch prefix

branchPrefix — scope out what GitHub branches Keystatic should interact with (when using github or cloud storage kind).

// keystatic.config.ts
import { config } from '@keystatic/core'

export default config({
  storage: { 
    kind: 'github',
    repo: 'Thinkmill/keystatic',
    branchPrefix: 'my-prefix/'
  }
})

Keystatic will only list branches starting with my-prefix/ in the Admin UI, and will only let you create new branches with that prefix.

Cloud

cloud — used to configure the Keystatic Cloud project if storage.kind is set to cloud.

Collections

collections — defines repeatable content structures, such as blog posts or testimonials.

Learn more in the Collections page.

Locale

locale — defines the locale for the project.

Singletons

singletons — defines one-off content structures, such as a settings or a contact page.

Learn more in the Singletons page.

Storage

storage — a required property defining Keystatic's storage strategy.

It's kind can be set to:

  • local to store and read files directly from your local file system
  • github to connect to a GitHub repository and read/write files to it
  • cloud to benefit from Keystatic Cloud's authentication and image hosting features
// keystatic.config.ts
import { config } from '@keystatic/core'

export default config({
  storage: { kind: 'local' }
})

User Interface

ui — allows customization of parts of the Keystatic Admin UI.

Learn more on the User Interface page.


Type signature

Find the latest version of the config type signature at: https://docsmill.dev/npm/@keystatic/core@latest#/.config