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({
  // ...
})

Configuration options

Keystatic's config requires at minimum a storage strategy.

It can also define collections and singletons:

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

export default config({
  // Required
  storage: {
    kind: 'local'
  },
  // Optional
  collections: {},
  singletons: {}
})

You can learn more about storage strategies on the Local vs. GitHub page.

For more about collections and sinlgetons, check the Collections and Singletons pages.

Example usage

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,
        }),
      },
    }),
  },
});

Type signature

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