Singletons

When you want a “one-of-a-kind” data entry, such as a “Settings” page or maybe a very specific set of fields for the “Homepage” of a website, you will want to use a singleton.

Example

Here's how you'd define a settings singleton:

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

export default config({
  // ...
  singletons: {
    settings: singleton({
      label: 'Settings',
      schema: {}
    }),
  },
});

Options

Entry layout

entryLayout — change the layout of the Admin UI for the singleton data entry.

Learn more on the Entry Layout page.

Format

format — provides options around the data format of your singleton.

Learn more on the Format Options page.

Label

label — defines the name of the singleton. This is used in the Admin UI.

Path

path — allows you to you specify where to store the singleton data:

path: 'custom/content/path/settings'

Learn more about the path option on the Content Organisation page.

Preview URL

previewURL — used to configure Real-time Previews of your content.

Schema

schema — defines the fields that the singleton should have.


Type signature

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