On this page

Configuration

One file describes your collections and fields. The admin, the API and validation all read from it.

prime.config.ts default-exports defineConfig({ ... }). Field descriptors are plain objects, so the same schema renders the admin forms and validates every write on the server.

import { collection, defineConfig, fields } from "@getprimecms/core";

export default defineConfig({
  name: "Notes",
  contentDir: "src/content",
  collections: {
    posts: collection({
      label: "Posts",
      singular: "post",
      directory: "posts",
      dateField: "date",
      draftField: "draft",
      fields: {
        title: fields.text({ required: true }),
        date: fields.date({ required: true, default: "today" }),
        tags: fields.list(),
        draft: fields.boolean({ default: true }),
      },
    }),
  },
});

Top-level options

Option Default What it does
name The folder’s name Site name shown in the admin header.
contentDir content Folder that holds one subfolder per collection. . is the project root, for collections that sit at paths such as src/lib/posts or _posts.
basePath /prime Where the admin and API are mounted.
collections Your collections, keyed by id.
storage file system githubStorage({...}) for hosts without a writable disk.
auth local only Who may use the admin. See Deploying.
access everyone is an admin Roles for Studio and Agency plans. See Access and roles.
agent off { model, instructions }. See The agent.
mediaDir public/media Where uploaded images are written.
mediaUrl /media The public address of mediaDir, for images written into content.
siteUrl Where your site is served when that is not the admin’s address, such as http://localhost:1313 for Hugo. Previews load from it.
branding { name, logo }: your name and logo in the admin instead of prime’s. Studio and Agency plans, and on localhost so you can preview it.
license Your license key, usually process.env.PRIME_LICENSE.

Collection options

Option What it does
label, singular Names shown in the admin: “Posts”, “New post”.
description A sentence shown at the top of the collection’s page in the admin.
directory Folder inside contentDir. Each collection needs its own. . is contentDir itself, for pages that sit directly in it.
recursive Also read entries in subfolders. An entry’s slug is its path, such as guides/setup. Another collection cannot live inside a recursive collection’s folder.
layout, bundleFile "bundle" stores each entry as a folder holding one file, as Hugo’s page bundles do (post/hello/index.md), so images can sit beside it. bundleFile is the file’s name without its extension: index by default, +page for SvelteKit routes. A bundle can be created and edited from the admin, but not renamed there, since its folder holds more than the entry.
fileName "{date}-{slug}" puts a date in front of the file name, as Jekyll’s _posts expects (2026-10-05-hello.md). The date is the entry’s dateField when there is one. Jekyll posts usually have none, so the date lives only in the name: the list reads it from there, and a new entry gets today’s.
frontmatter "toml" writes new entries with TOML between +++ lines, as Hugo does. The default is YAML between --- lines. Existing files are read and edited in whichever they already use, so a collection can hold both.
format md or mdx for new entries. Existing files keep their format.
titleField Field shown as the entry title. Defaults to title.
dateField A date field used to sort newest first.
draftField A boolean field shown as a Draft badge.
url Where an entry appears on the site, such as /posts/{slug} or / for a home page. Turns on Preview in the editor. Use {slug}, any field name, or {year}, {month} and {day} from dateField.
body Set to false for entries that are only fields, such as site settings. The admin hides the body editor and keeps any body already in the file.
singleton Makes the collection one entry with this file name, such as home or settings. Singletons appear under Site in the admin, open straight into the editor, and cannot be renamed or deleted. Several can share a directory.
sections Groups the fields under headings, for entries with many of them, such as site settings. Each section has a label, an optional description and the fields it holds, in order. Fields no section names follow under More. On a wide screen, an entry without a body lists its sections beside the form.
sections: [
  { label: "Home hero", fields: ["heroTitle", "heroText", "heroButton"] },
  { label: "Footer", description: "Shown on every page.", fields: ["footerText", "copyright"] },
],

Short fields, such as numbers, choices, dates and one-line text, sit two to a row wherever the form has room, inside groups too.

Preview

Give a collection a url and the editor gets a Preview button. It opens the entry beside the editor at phone, tablet or full width, and reloads after every save. It shows the saved file, not unsaved edits, and says so while you have changes.

If your site runs on a different address from the admin, as with Hugo or Jekyll next to primecms dev, set siteUrl:

export default defineConfig({
  siteUrl: "http://localhost:1313",
  collections: { posts: collection({ url: "/posts/{slug}", /* ... */ }) },
});

With GitHub storage the preview shows the live site, which picks up your saves after its next build.

Markdown and MDX in the editor

The visual editor writes back only the parts of a body you changed. Everything else, including formatting you chose such as __bold__ or * bullets, stays exactly as it was, so a one-word fix is a one-line diff.

In MDX, imports, exports, components and expressions show as blocks labelled with what they are. They are saved exactly as written; use Edit source on a block to change it. Tables, footnotes and raw HTML work the same way in plain Markdown. prime refuses to save MDX that does not parse, so a broken component never reaches your site build, whether a person or the agent wrote it.

Field types

Helper Stored as
fields.text(), fields.textarea() string
fields.slug() string
fields.number() number
fields.boolean() true or false
fields.date() YYYY-MM-DD, with a time if you ask for one
fields.select() one of its option values
fields.list() list of strings
fields.url() string
fields.image() path, or { src, alt }, or a list of them
fields.file() path or https:// link
fields.reference() slug, or a list of slugs
fields.group() object, or a list of objects

Every option, an example of each and how the admin shows it are in Field types.

Files prime does not model

Frontmatter keys that are not in your schema are kept exactly as they are. A save changes only what you changed: an entry saved with no edits comes back byte for byte, an edited field replaces just its own lines, and comments, key order, quoting, inline lists, line endings and the gap before the body stay as they were. A save from the admin produces a small, readable diff.

Files that already exist keep whatever names your tooling gave them: My_File.md, _index.md, 智能合约开发.md or 2022 Annual Summary.md all work, as do .md, .mdx and Jekyll’s .markdown. Only hidden files and names that try to leave the folder are ignored. New entries use lowercase letters, numbers and single hyphens.

A singleton collection can also be a page in the project root, such as Jekyll’s about.md, when contentDir is .. Only that file is read, so the rest of the root (a README, a Gemfile) is never listed.