Getting Started
Installation
pnpm add laikacmsBasic Example
import { buildJsonApi } from 'laikacms/storage-api';
import { FileSystemStorageRepository } from 'laikacms/storage-fs';
import { rawSerializer } from 'laikacms/storage-serializers-raw';
const repo = new FileSystemStorageRepository('./content', { md: rawSerializer }, 'md');
const api = buildJsonApi({ repo });
export default { fetch: api.fetch };Note:
rawSerializerstores only thebodyfield of each content object as plain text. Passing any other fields (e.g.title,tags) will throw an error at write time to prevent silent data loss. If you need to persist multi-field content, usejsonSerializerinstead.
The body convention
Content in laikacms is always an object — you cannot store a raw string directly. When all you have is a raw string (plain text, markdown, HTML, …), the convention is to wrap it in a body field:
{ "body": "<content>" }Markdown with frontmatter follows the same shape — frontmatter fields sit alongside body:
{ "title": "Hello", "tags": ["intro"], "body": "# Hello\n\nMy first post." }This is just a convention: the protocol itself never interprets the content object. Serializers, however, build on it — rawSerializer persists exactly the body field as plain text, and the markdown serializer writes body as the document body with the remaining fields as frontmatter.
Cloudflare Workers
import { buildJsonApi } from 'laikacms/storage-api';
import { R2StorageRepository } from 'laikacms/storage-r2';
import { rawSerializer } from 'laikacms/storage-serializers-raw';
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const repo = new R2StorageRepository(env.CONTENT_BUCKET, { md: rawSerializer }, 'md');
return buildJsonApi({ repo }).fetch(request);
},
};With Decap CMS
See Decap Integration.
Next Steps
- Architecture - Design patterns
- API Reference - Endpoints
- Packages - All packages
- Deployment - Production setup