Learn how to create, manage, and organize content in SonicJS AI.
SonicJS AI supports flexible content types that can be customized for your needs:
- Pages - Static pages like About, Contact, etc.
- Posts - Blog posts, news articles, and time-based content
- Media - Images, videos, documents, and other files
You can define custom content types by extending the base schema:
// Example: Product content type
export const productSchema = z.object({
title: z.string().min(1),
description: z.string(),
price: z.number().positive(),
category: z.string(),
inStock: z.boolean().default(true),
images: z.array(z.string()).optional()
})-
Navigate to Content - Go to
/admin/contentin your browser -
Click "New Content" - Start creating a new content item
-
Fill in Details:
- Title: The main title of your content
- Slug: URL-friendly identifier (auto-generated from title)
- Content Type: Select the appropriate type
- Status: Draft, Published, or Archived
- Content: Rich text content with markdown support
-
Save or Publish - Save as draft or publish immediately
Create content programmatically using the REST API:
const response = await fetch('/api/content', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
title: 'My New Article',
slug: 'my-new-article',
type: 'post',
content: '# Welcome\n\nThis is my first article...',
status: 'published'
})
})
const newContent = await response.json()SonicJS AI supports a flexible content workflow:
- Draft - Work in progress, not visible to public
- Published - Live and visible to everyone
- Archived - Hidden but preserved for reference
graph LR
A[Draft] --> B[Review]
B --> C[Published]
C --> D[Archived]
D --> A
B --> A
The admin interface includes a powerful markdown editor with:
- Live preview - See formatted content as you type
- Syntax highlighting - Code blocks with syntax highlighting
- Media insertion - Drag and drop images directly
- Table support - Create and edit tables easily
- Link management - Easy linking to internal and external content
# Headers
## Subheaders
**Bold text** and *italic text*
- Bulleted lists
- With multiple items
1. Numbered lists
2. Also supported
[Links](https://example.com) and 
`Inline code` and:
Code blocks with syntax highlighting
> Blockquotes for emphasis
| Tables | Are | Supported |
|--------|-----|-----------|
| Row 1 | A | 123 |
| Row 2 | B | 456 |
Group related content into collections:
- Blog Posts - All your blog articles
- Products - E-commerce product catalog
- Team Members - Staff profiles and bios
- Testimonials - Customer reviews and feedback
Organize content with:
- Categories - Hierarchical organization
- Tags - Cross-cutting labels and keywords
- Custom Fields - Additional metadata specific to your needs
The admin interface provides powerful search capabilities:
// API search example
const results = await fetch('/api/content?search=tutorial&type=post&status=published')Support for various file types:
- Images - JPG, PNG, GIF, WebP
- Documents - PDF, DOC, DOCX, TXT
- Videos - MP4, WebM, MOV
- Audio - MP3, WAV, OGG
Automatic image optimization:
- Resizing - Multiple sizes for different use cases
- Compression - Optimized file sizes
- Format conversion - WebP for modern browsers
- CDN delivery - Fast global content delivery
Reference media files in your content:

[Download PDF](/media/def456/document.pdf)Track changes to your content:
- Automatic saving - All changes are tracked
- Rollback capability - Restore previous versions
- Change comparison - See what changed between versions
- Audit trail - Track who made changes and when
// Get version history
const versions = await fetch('/api/content/123/versions')
// Restore a previous version
await fetch('/api/content/123/restore/5', { method: 'POST' })- Plan your content types before you start creating content
- Use consistent naming for categories and tags
- Write SEO-friendly titles and descriptions
- Organize with clear hierarchies using collections
- Optimize images before uploading
- Use appropriate content types for better organization
- Regular content audits to remove outdated material
- Leverage caching for frequently accessed content
- Review content before publishing
- Use proper user permissions for content creation
- Validate user inputs in custom content types
- Monitor content changes through audit logs
Extend content types with custom fields:
export const eventSchema = z.object({
title: z.string(),
content: z.string(),
startDate: z.string().datetime(),
endDate: z.string().datetime(),
location: z.string(),
maxAttendees: z.number().optional(),
registrationRequired: z.boolean()
})Link related content:
{
"title": "Advanced JavaScript",
"content": "...",
"relatedPosts": ["post-123", "post-456"],
"author": "user-789"
}Set content to publish automatically:
{
"title": "Weekly Newsletter",
"content": "...",
"status": "scheduled",
"publishAt": "2024-02-01T09:00:00Z"
}Content not saving:
- Check your authentication token
- Verify required fields are filled
- Ensure you have proper permissions
Images not displaying:
- Verify file upload was successful
- Check file path and permissions
- Ensure proper image formats
Rich text editor issues:
- Clear browser cache
- Check for JavaScript errors
- Try refreshing the page
Need more help? Check our FAQ or contact support.