Content Engine

Content Engine Overview

Declare a content type once in TypeScript and get a Postgres table, Zod schemas, CRUD routes, staff permissions, and AdminCP screens.

Content Engine eliminates boilerplate for structured data. From a single TypeScript definition, it automatically generates a PostgreSQL table, Zod validation schemas, Hono CRUD endpoints, staff permissions, and AdminCP data management screens.

Quick start

1. Declare the Definition

plugins/blog/src/content/category.ts
import { defineContentType, field } from "@vitnode/core/content"

export const categoryContentType = defineContentType({
  id: "blog.category",
  tableName: "blog_categories",
  fields: {
    name: field.text({ required: true, minLength: 2, maxLength: 100 }),
    slug: field.slug({ from: "name", required: true }),
  },
})

2. Compile the Database Model

plugins/blog/src/database/categories.ts
import { createContentModel } from "@vitnode/core/content/server"
import { categoryContentType } from "../content/category"

export const categoryContent = createContentModel(categoryContentType)
export const blog_categories = categoryContent.table

3. Build & Migrate

Build and migrate
bun run build:plugins && bun run db:migrate
pnpm build:plugins && pnpm db:migrate
npm run build:plugins && npm run db:migrate

PostgreSQL now contains your table, and AdminCP screens are ready at /admin/content/blog/categories.


Generated Features

LayerOutput
DatabaseDrizzle schema table with foreign keys and index constraints
ValidationStrongly typed Zod schemas for create, update, and filter operations
Hono APIComplete CRUD endpoints with staff permission protection
AdminCP UIData table with cursor pagination, sorting, search, and AutoForm dialogs
Eventscontent.{id}.created, content.{id}.updated, and content.{id}.deleted

Documentation Guides