Introduction
Aphex CMS — a Sanity-inspired content management system that runs inside your SvelteKit app.
Aphex is a CMS built with SvelteKit and Svelte 5, taking its schema-driven approach from Sanity. It runs inside your SvelteKit app rather than beside it: the same app that serves your site serves the admin, so content is read through a typed function call instead of a network hop, and live preview is a component render rather than an integration.
The architecture is ports-and-adapters, so the database is a choice rather than an assumption. Two adapters are meant for real use: PostgreSQL (Drizzle ORM) and SQLite/libsql (local file: databases and Turso). They are peers, not tiers — both run the same cross-dialect conformance suite, and SQLite is not a reduced version of the product.
A third, PGlite (embedded Postgres, no server), exists for automated tests: it gives the test suite Postgres semantics — row-level security included — with nothing to install. It is not recommended for development or production; its on-disk storage has proven prone to corruption. Develop against the database you deploy on.
The fastest way to try it is with the create-aphex scaffolder:
pnpm create aphex@latest
# 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 — PostgreSQL (Drizzle ORM) and SQLite/libsql (local files and Turso) behind one
DatabaseAdaptercontract. Switching is a config change. PGlite is available too, but for tests rather than dev or production. - SvelteKit-native — runs as part of your SvelteKit app. No separate server to manage.
- Visual editing — live preview with stega-encoded click-to-edit overlays, so an editor clicks the text on the page to edit the field behind it.
- Portable Text rich content — a TipTap-backed block editor with custom block types, inline objects, marks, and annotations.
- Events & durable jobs — an append-only event log, transactional outbox, and DB-backed queue with leases, backoff and dead-lettering; powers scheduled publishing and plugin event consumers.
- AI built in — an in-admin assistant and a Streamable HTTP MCP server for clients like Claude Code, sharing one capability-filtered tool set.
- 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/sqlite-adapter | SQLite via libsql (local file: databases and Turso) |
@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