Dyrected
Examples & RecipesApplication Patterns

Workflows

Application patterns for draft, review, and publishing flows when content should move through named states before it goes live.

Use these patterns when content needs more than simple CRUD. Workflows help when a document should move through a defined editorial process, with clear transitions and role-aware control over who can change its public state.

In Cloud, use workflows for editorial states, review, publishing, and preview. Cloud content events and webhooks are still coming soon, so do not rely on Cloud to run arbitrary workflow handler code yet.

Add draft, review, and publishing states

Problem: editors need to work on content privately, send it for review, and only publish it when the right person approves.

This pattern attaches Dyrected’s editorial workflow to a collection so documents move through named states instead of going live immediately. It is a good fit for content teams, documentation teams, and any publishing flow that needs controlled review.

Example implementation

import { defineCollection, defineRichTextField, defineTextField, publishingWorkflow } from "@dyrected/core";

export const Posts = defineCollection({
  slug: "posts",
  workflow: publishingWorkflow(),
  fields: [
    defineTextField({ name: "title", label: "Title", required: true }),
    defineRichTextField({ name: "body", label: "Body", required: true }),
  ],
});

Read the full docs:

Configure preview URLs with token mode

Problem: editors need to preview draft content on the real route before it is published.

This pattern sets a preview URL and token-based preview mode so the Admin can open a draft route without publishing the document first. It is most useful for server-rendered or static frontends where draft data needs to be resolved through a preview token.

Example implementation

import { defineCollection, defineTextField } from "@dyrected/core";

export const Docs = defineCollection({
  slug: "docs",
  admin: {
    useAsTitle: "title",
    previewUrl: "slug ? '/docs/' + slug : null",
    previewMode: "postMessage",
    urlPattern: "/docs/{slug}",
  },
  fields: [
    defineTextField({ name: "title", label: "Title", required: true }),
    defineTextField({ name: "slug", label: "Slug", required: true, unique: true }),
  ],
});

Read the full docs:

On this page

Dyrected| Cloud

Get your backend ready in minutes

Use a managed database, storage, APIs, and admin dashboard without setting up the infrastructure yourself.

Set Up My Backend