Dyrected
API Reference

Configuration Reference

Detailed reference for the Dyrected configuration object and content contract.

Your dyrected.config.ts is the source of truth for your entire application. It defines your data model (the "Content Contract"), access rules, and system integrations.

Core Configuration (DyrectedConfig)

The defineConfig helper expects an object with the following properties:

PropertyTypeDescription
collectionsCollectionConfig[]List of content collections (multi-entry).
globalsGlobalConfig[]List of global singletons (single-entry).
dbDatabaseAdapterThe database adapter to use (e.g., @dyrected/db-postgres).
storageStorageAdapter(Optional) The storage adapter for media uploads.
emailEmailConfig(Optional) Enables the forgot-password flow. Provide a send function wired to any email library.
redisRedisConfig(Optional) Connection details for Redis (required for Cloud).

Collection Configuration (CollectionConfig)

PropertyTypeDescription
slugstringUnique identifier used in API paths and database tables.
fieldsField[]The list of fields that define this collection's schema.
labelsobjectSingular and plural labels for the Admin UI.
authbooleanEnable built-in authentication for this collection.
uploadboolean | objectEnable file uploads and define image sizes/mime types.
accessobjectControl read, create, update, and delete permissions.
hooksobjectLifecycle hooks (e.g., beforeChange, afterRead).
adminobjectUI customizations like useAsTitle and defaultColumns.

Global Configuration (GlobalConfig)

Globals follow a similar structure to collections but are intended for singleton data.

PropertyTypeDescription
slugstringUnique identifier for the global.
fieldsField[]The schema for this global.
labelstringDisplay name in the Admin UI.
accessobjectControl read and update permissions.
hooksobjectLifecycle hooks (same as collections, excluding delete).

Field Configuration (Field)

Every field in a collection or global supports these base properties:

PropertyTypeDescription
namestringThe key used in the database and JSON responses.
typeFieldTypeThe type of field (e.g., text, richText, relationship).
labelstring(Optional) Display name in the Admin UI. Defaults to a title-cased name.
requiredboolean(Optional) Enforcement of data presence.
uniqueboolean(Optional) Enforcement of unique values in the collection.
defaultValueany(Optional) The initial value for new entries.
adminobjectUI options: placeholder, description, readOnly, hidden, condition.
accessobjectField-level permissions.
hooksobjectField-level lifecycle hooks.

Type-Specific Properties

  • select / multiSelect: Requires options array (strings or { label, value }).
  • relationship: Requires collection (slug of the target collection).
  • array / object: Requires a nested fields array.
  • blocks: Requires a blocks array of Block definitions.

Content Contract Best Practices

  1. Keep Slugs Stable: Changing a slug after deployment will result in a new database table and orphaned data.
  2. Use object for Grouping: Use the object field type to group related fields in the UI and API response without creating new tables.
  3. Leverage condition: Use admin.condition to show/hide fields based on the values of other fields in the same document.

Email Configuration

The email config enables transactional emails for all auth collection events (welcome, invite, password reset, password changed). In development with no config set, emails are automatically intercepted by Ethereal so you can preview them without any setup.

export default defineConfig({
  email: {
    from: '[email protected]',
    send: async ({ to, subject, html }) => {
      // wire in Resend, Nodemailer, Postmark, etc.
    },
  },
})

See Email for the full guide — provider examples, the Ethereal dev fallback, and custom template overrides.


JSON Response Contract

When you fetch data from the API, Dyrected returns a standardized JSON structure based on your fields:

  • Relationships: Returned as the id string (by default) or the full object if expanded.
  • Blocks: Returned as an array of objects, each containing a blockType (matching the block slug) and its corresponding data.
  • Rich Text: Returned as a JSON object compatible with Tiptap/ProseMirror.
  • Dates: Returned as ISO-8601 strings.

On this page