Introduction
Aphex CMS — a database-agnostic, Sanity-inspired content management system built with SvelteKit.
Aphex is a headless CMS built with SvelteKit and Svelte 5. It takes inspiration from Sanity's schema-driven approach while being fully database-agnostic through a ports and adapters architecture.
The fastest way to try it is with the create-aphex scaffolder:
pnpm create aphex
# or: npm create aphex@latestHead to Getting Started for the full walkthrough.
Key Features
- Schema-driven — define your content model with TypeScript. Get a full admin UI, REST API, GraphQL API, and database schema automatically.
- Database-agnostic — ships with PostgreSQL via Drizzle ORM. Bring your own adapter for any database.
- SvelteKit-native — runs as part of your SvelteKit app. No separate server to manage.
- Draft / published workflow — auto-save every couple of seconds, hash-based change detection, one-click publish.
- Version history — every draft save and publish is captured. Editors can preview and restore any prior version.
- Singletons — mark a schema as
singleton: trueto model global content (site nav, footer, settings) as a single auto-resolving row. - Multi-tenancy — organizations with PostgreSQL row-level security and a parent / child hierarchy.
- Capability-based access control — edit built-in roles, define custom roles per organization, and gate schemas / fields by role or policy function.
- Authentication — Better Auth integration with email + password, API keys, and email-verified sign-up.
- S3-compatible storage — AWS S3, Cloudflare R2, MinIO, or local filesystem.
- Hono-powered HTTP layer — register custom routes and middleware via the
api(app)config hook. - Email — Resend or any SMTP provider via the Nodemailer adapter; Mailpit by default in dev.
Architecture
Aphex follows a hexagonal (ports & adapters) architecture. The core engine (@aphexcms/cms-core) defines interfaces for database, storage, authentication, email, and cache. Separate packages provide implementations:
| Package | Purpose |
|---|---|
@aphexcms/cms-core | Core engine, admin UI, Hono HTTP routes, built-in GraphQL, types |
@aphexcms/postgresql-adapter | PostgreSQL + Drizzle ORM adapter |
@aphexcms/storage-s3 | S3-compatible storage (R2, AWS S3, MinIO) |
@aphexcms/resend-adapter | Email via Resend |
@aphexcms/nodemailer-adapter | Email via Nodemailer / SMTP (includes a Mailpit shorthand) |
@aphexcms/ui | Shared shadcn-svelte component library |
Next Steps
Getting Started
Create your first Aphex project in under 5 minutes.
Schemas
Define your content model with document and object types.
Singletons
Model site-wide content like navigation and settings.
Version History
Browse every change and restore prior versions.
Configuration
Every option in aphex.config.ts, including the Hono `api(app)` hook.
Access Control
Capabilities, custom roles, and schema / field-level access rules.
Last updated on