Cosmictron is a database that runs your application logic. Write reducers in Rust or TypeScript, deploy as a module, and get real-time subscriptions, auth, and security — no app server, no pub/sub layer, no glue code. One binary replaces your whole backend stack.
Only changed rows are recomputed, even across joins and aggregations. O(delta) instead of O(N) — powered by DBSP circuits.
Declarative row-level security that works with subscriptions and joins. Policies are SQL predicates, automatically injected into every query.
Self-hosted, truly open-source (MIT/Apache 2.0). Your data, your infrastructure, your terms.
V8 runtime with full npm ecosystem access. Write modules in TypeScript with the libraries you already know.
Define your tables and logic in Rust. Subscribe from TypeScript. That's it.
#[table(name = "messages", public)]
pub struct Message {
#[primary_key] #[auto_inc]
pub id: u64,
pub sender: Identity,
pub text: String,
pub ts: Timestamp,
}
#[reducer]
fn send(ctx: &ReducerContext, text: String) {
Message::insert(ctx.db, Message {
id: 0, sender: ctx.sender,
text, ts: ctx.timestamp,
});
} import { Cosmictron } from "@cosmictron/sdk";
const db = new Cosmictron({
host: "localhost:3000",
module: "chat",
});
// Subscribe — only deltas are sent
db.subscribe("SELECT * FROM messages");
db.on("messages", (change) => {
for (const msg of change.inserts) {
console.log(`${msg.sender}: ${msg.text}`);
}
});
db.call("send", { text: "Hello!" }); | Cosmictron | Firebase | Supabase | SpacetimeDB | |
|---|---|---|---|---|
| Embedded business logic | WASM + V8 | Cloud Functions (separate) | Edge Functions (separate) | WASM only |
| Real-time subscriptions | DBSP incremental | Yes (full re-eval) | Yes (row-level) | Yes (full re-eval for joins) |
| Incremental joins/aggs | Yes | No | No | No |
| Declarative RLS | Yes | No (Security Rules DSL) | Yes (Postgres RLS) | No |
| TypeScript modules | Native V8 | Node.js (separate service) | Deno (separate service) | No (C# or Rust) |
| Self-hosted | Yes (MIT/Apache 2.0) | No | Yes | BSL 1.1 |
We're building managed Cosmictron hosting. Join the waitlist to get early access.