Self-host SpacetimeDB
v2.15.0Relational database you deploy your app logic into
docker run --rm --pull always -p 3000:3000 clockworklabs/spacetime start- Stars
- 25 539
- Port
- 3000 (Standalone server: HTTP endpoints and the real-time subscribe websocket)
clockworklabs/spacetimeWhat is SpacetimeDB?
SpacetimeDB fuses a relational store with an application server, because business logic gets compiled into a module and published straight into the engine: browsers, desktop programs and game clients then talk to the database itself instead of a middle-tier API. Rust, C#, TypeScript and C++ are all supported for modules, which declare tables plus reducers; a reducer invocation is atomic under full ACID rules, and clients holding a subscription receive row changes without polling. State stays resident in memory, durability coming from an on-disk log replayed at restart, and since the 2.0 line reads wait until writes are durable. Clockwork Labs built BitCraft Online's entire backend as one module, so the sweet spot is low-latency shared state: chat, collaborative editors, live dashboards, multiplayer sessions. Client identity arrives as OpenID Connect tokens from any conforming provider, procedures may call other HTTP services outbound, SQL works over HTTP, and the PostgreSQL wire protocol can be switched on at startup with a flag. To run it yourself, pull the published image and map port 3000, or install the CLI on Ubuntu, macOS or Windows and wrap the standalone binary in a systemd unit behind Nginx with a Let's Encrypt certificate, since that binary has no TLS of its own; a Cargo source build is documented as well. Two limits matter: the licence is the Business Source License, not an OSI open-source one (single production instance allowed, reselling access as a hosted database service is not, AGPL v3 plus linking exception later), and Maincloud is the company's managed alternative, free tier and paid plans included.
SpacetimeDB alternatives
SurrealDBSelf-hosted, source-available Rust database unifying documents, graphs, vectors and time-series, with live queries and row-level permissions in SurrealQL.CompareSurrealDB with SpacetimeDB
instantSelf-hosted, open-source backend-as-a-service: relational queries, realtime sync, offline caching, auth, storage and permission rules on PostgreSQL.Compareinstant with SpacetimeDB
AppwriteThe open-source cloud for agents & devs. Including Auth, Databases, Storage, Functions, Messaging, Hosting, Realtime, WAF and moreCompareAppwrite with SpacetimeDB
gtsdbGTSDB is a self-hosted, open-source time-series database in Go using WAL-first architecture for sub-millisecond reads and 233x faster writes than InfluxDB.Comparegtsdb with SpacetimeDB
Atomic ServerAtomicServer is a self-hosted, open-source headless CMS and real-time database for atomic.place with local-first sync, collaborative docs, tables, chat, and AI via MCP.CompareAtomic Server with SpacetimeDB
NakamaSelf-hosted, open-source game backend with realtime plus turn-based gameplay, matchmaking, leaderboards, chat, player data, and an embedded admin console.CompareNakama with SpacetimeDB
directusDirectus is a self-hosted headless CMS that puts instant REST and GraphQL APIs, a no-code admin Studio, media library and an MCP server on top of your own SQL database.Comparedirectus with SpacetimeDB
open-sparrowOpenSparrow is a self-hosted, open-source PHP platform generating CRUD apps, dashboards, calendars from JSON schema on PostgreSQL. Includes RAG, workflows, Kanban, 2FA.Compareopen-sparrow with SpacetimeDB
All self-hosted alternatives to Firebase → All self-hosted alternatives to Convex → All self-hosted alternatives to Photon →
Should you self-host SpacetimeDB?
SpacetimeDB scores 75/100 on selfhost.directory (how scoring works) and ranks #7 of 38 in Databases. It has 25 539 GitHub stars, +217 in the last 30 days.
It shipped 10 stable releases in the past year. The latest, v2.15.0, came out on 6 November 2026. New versions land roughly every 7 days.
Setup is moderate: expect some configuration beyond a single command. An official Docker image is available. It is Other-licensed and written mostly in Rust.
Its closest alternative on selfhost.directory is supabase (90/100, 114 754 stars). It scores higher overall, so compare the two before you pick. See SpacetimeDB vs supabase side by side.
Features
- ACID Transactions
- Automatic schema migrations
- Confirmed reads
- Embedded application logic
- Generated type-safe client bindings
- In-memory engine with commit-log recovery
- Module logging
- Multi-language server modules
- PostgreSQL wire protocolOff by default; enabled with the --pg-port startup option.
- Procedures with outbound HTTP
- Real-time data sync
- SQL queries over HTTP
- Subscribable views
- Watch-mode development workflow
FAQ
How does real-time sync work?
Clients declare subscriptions with the typed query builder (raw SQL subscriptions also exist), and the engine pushes incremental changes into a local client cache you query without round trips.
How does data persistence work?
Everything is written to a commit log comparable to a write-ahead log, and on restart that log is replayed so the database returns to its exact prior state.
What are procedures?
Procedures extend reducers with manual transaction control and outbound HTTP calls to other services, and clients may invoke them over HTTP.
What are views?
Views are read-only functions computing derived data from tables; clients can subscribe to them and they refresh automatically as underlying rows change.
What are reducers?
Reducers change database state inside a transaction, so either every change commits or none does; think of them as transactional RPC endpoints.
What are tables?
Tables are the primary storage, defined through your language's types, with support for primary keys, unique constraints and indexes, and clients can subscribe to them.
What is a "module"?
A module is your server-side code compiled to WebAssembly (or bundled JavaScript for TypeScript), defining tables, reducers, views and procedures, and uploaded with the publish command.
How is SpacetimeDB different from a regular database (PostgreSQL, MySQL)?
It keeps data in memory, runs your logic inside the engine as WebAssembly and pushes updates to clients, and is aimed at real-time work rather than batch processing or analytics.
How is SpacetimeDB different from Firebase / Supabase?
Those platforms keep your logic elsewhere (cloud or edge functions) on top of a database, while here the full application is a module in a real language running inside the database.
How is SpacetimeDB different from Mirror / Netcode / Photon / other networking libraries?
Networking libraries only move messages and leave you to write the server, state and persistence; here the product takes over the whole server side.
Can I self-host SpacetimeDB?
Yes, run it on your own infrastructure with the start command or with the published Docker image, or use the hosted Maincloud platform instead.
Is SpacetimeDB open source?
Not in the OSI sense: it is source-available under BSL 1.1 and later converts to AGPL v3 with a linking exception, so your own app code need not be released.
Is SpacetimeDB only for games?
No, it is meant for any low-latency real-time application, including chat, collaboration tools, dashboards and IoT; games are simply the most demanding showcase.
How is SpacetimeDB different from a traditional backend?
You skip the web server, endpoint layer, connection pooling and caching plumbing: your published module is the backend, and clients call reducers and subscribe to live data.
What is SpacetimeDB?
It is a relational database you also deploy your server code into, so clients talk straight to the database rather than to an API tier you build and operate.
More in Databases
storStor is a self-hosted, open-source JSON database that exposes a REST-like HTTP API for CRUD operations, using MongoDB as its storage backend and Node.js for the server.
SurrealDBSelf-hosted, source-available Rust database unifying documents, graphs, vectors and time-series, with live queries and row-level permissions in SurrealQL.
tidbSelf-hosted, open-source distributed SQL database with MySQL compatibility, ACID transactions, HTAP analytics and vector search in one engine.
Tile38Self-hosted, open-source in-memory geolocation store and spatial index with real-time geofencing, webhook alerts and a Redis-compatible API.
timeplusSelf-hosted, open-source streaming SQL engine for real-time analytics and AI — a lightweight alternative to ksqlDB and Flink powered by ClickHouse.
timescaleTimescaleDB is an open-source, self-hosted PostgreSQL extension for time-series and event data, with hypertables, columnar compression, and continuous aggregates.
ValkeySelf-hosted, open-source Valkey is an in-memory key-value database for caching, queues and primary data, with replication, Sentinel failover and cluster sharding.
VectorChordSelf-hosted PostgreSQL extension for scalable vector search using RaBitQ quantization, compatible with pgvector syntax, enabling 100M+ vectors on modest hardware.
victoriametricsOpen-source, self-hosted time series database and monitoring backend that replaces Prometheus or Graphite as Grafana's metrics store, with PromQL and MetricsQL querying.
yantrikdb-serverSelf-hosted memory DB for AI agents with recall, graph, contradiction detection, decay. Embedded lib, MCP server, or replicated cluster.
AntflyAntfly is a self-hosted, open-source Zig database unifying full-text, vector, and graph search with built-in ML for embeddings, reranking, and RAG.
Apache CassandraSelf-hosted, open-source distributed NoSQL database: a masterless partitioned row store with multi-datacenter replication, queried with CQL over the native protocol.
0 comments