Content Management
Creating Collections
Collections are TypeScript config objects registered at app startup — no database table required.
// src/collections/blog-posts.collection.ts
import type { CollectionConfig } from '@sonicjs-cms/core'
export default {
name: 'blog_post',
displayName: 'Blog Post',
slug: 'blog-posts',
description: 'Article content collection',
schema: {
type: 'object',
properties: {
title: { type: 'string', title: 'Title', required: true, maxLength: 200 },
content: { type: 'lexical', title: 'Content', required: true },
publishedAt: { type: 'datetime', title: 'Published Date' },
},
required: ['title', 'content'],
},
managed: true,
isActive: true,
} satisfies CollectionConfig// src/index.ts — register before createSonicJSApp
import { registerCollections, createSonicJSApp } from '@sonicjs-cms/core'
import blogPostsCollection from './collections/blog-posts.collection'
registerCollections([blogPostsCollection])
export default createSonicJSApp({ plugins: { register: [] } })Field Types
- string: Single-line text with validation
- lexical: Rich text editor
- number: Numeric input with min/max constraints
- boolean: Checkbox with custom labels
- datetime: Date/time picker
- select: Dropdown with single/multi-select
- slug: URL slug with auto-generation
- user: User reference picker
- media: File picker with preview
Source captured: 2026-10-11