@saastro/cms
v0.2.3
Published
CMS integration for Astro - Saastro ecosystem
Maintainers
Readme
@saastro/cms
Git-based CMS integration for Astro. Add a full-featured admin panel and REST API to any Astro site. Content is stored as Markdown in your GitHub repository.
Installation
pnpm add @saastro/cmsPeer dependencies: astro ^4/^5, react ^18/^19, react-dom ^18/^19
Quick Start
// astro.config.ts
import saastrocms from '@saastro/cms';
export default defineConfig({
integrations: [
saastrocms({
github: { owner: 'your-org', repo: 'your-site' },
}),
],
});This gives you:
- Admin panel at
/admin - REST API at
/api/cms/* - Visual editor support via
data-saastrocms-fieldattributes
Authentication
GitHub OAuth (default)
GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET=...
SESSION_SECRET=...
ENCRYPTION_KEY=...Token Auth
import { createAltAuthMiddleware } from '@saastro/cms/auth';
createAltAuthMiddleware({
method: 'token',
token: { tokens: [{ token: 'secret', user: { id: '1', name: 'Admin', role: 'admin' } }] },
});Basic Auth / No Auth
createAltAuthMiddleware({ method: 'basic', basic: { users: [...] } });
createAltAuthMiddleware({ method: 'none' }); // dev onlyStorage
import { initStorage } from '@saastro/cms/storage';
// Production
initStorage({ type: 'github', github: { owner: '...', repo: '...', token: '...' } });
// Development
initStorage({ type: 'memory' });Collections
import { defineCollection } from '@saastro/cms';
import { z } from 'zod';
const blog = defineCollection({
name: 'blog',
schema: z.object({ title: z.string(), date: z.coerce.date() }),
});Development
pnpm dev # Watch mode
pnpm build # Production build
pnpm test # Run tests
pnpm typecheck # Type checkingLicense
MIT
