Favicon of SpacetimeDB

SpacetimeDB

SpacetimeDB is a relational database that executes your application logic and syncs state to clients directly, cutting out the server tier.

SpacetimeDB website screenshot
SpacetimeDB GitHub repository preview

SpacetimeDB combines a relational database and an application server into one process. You write your schema and business logic as a module (in Rust, C#, TypeScript, or C++), upload it into the database, and clients connect straight to it, no separate backend in between. It's aimed at developers building real-time multiplayer games, live collaborative apps, or any system where clients need instant, consistent state updates without hand-rolled sync layers.

Key features

  • In-database logic: application code runs as compiled modules inside the database itself, so there's no separate web or game server to deploy.
  • Tables and reducers: define your data as tables and your business logic as reducers (functions clients call), similar to stored procedures but as the primary API.
  • Automatic state sync: clients subscribe to tables and get pushed updates in real-time when data changes, no polling or manual refetching.
  • ACID guarantees: transactions behave like a traditional RDBMS, with in-memory state for speed and an on-disk commit log for durability and crash recovery.
  • Multi-language modules: write server-side modules in Rust, C#, TypeScript, or C++.
  • Multi-platform clients: connect from TypeScript (React, Next.js, Vue, Svelte, Angular, Node.js, Bun, Deno), Rust, C# (including Unity), or C++ (Unreal Engine).
  • Single binary deployment: your whole application (data plus logic) ships and runs as one module, removing the need for containers, Kubernetes, or separate DevOps pipelines.
  • Proven at scale: powers the MMORPG BitCraft Online, where chat, items, terrain, and player positions all run through a single SpacetimeDB module for thousands of concurrent players.

Ideal use cases

SpacetimeDB fits projects that need real-time, stateful synchronization between many clients and a shared source of truth: multiplayer games, MMORPGs, live dashboards, collaborative editors, or chat apps where every client must see the same state instantly. It works well when you want to avoid building and maintaining a separate server tier, a caching layer, and a sync protocol by hand.

It is not a good fit if you need a conventional stateless REST/GraphQL API backed by a standard SQL database with existing ORM tooling, since the entire model here is different: logic lives inside the database as reducers, not as separate service code. It's also not the right choice if your workload is primarily batch analytics, data warehousing, or if you need to run on infrastructure that can't run the SpacetimeDB binary or module runtime. Teams already deeply invested in a traditional three-tier architecture (client, server, database) will face a real architectural shift adopting this.

Installation

Install the CLI on macOS/Linux:

curl -sSf https://install.spacetimedb.com | sh

On Windows (PowerShell):

iwr https://windows.spacetimedb.com -useb | iex

Log in (opens a browser to authenticate with GitHub, linking your identity so you can publish databases):

spacetime login

Start a project from a template, which publishes it and watches for changes:

spacetime dev --template chat-react-ts

Alternatively, run SpacetimeDB with Docker:

docker run --rm --pull always -p 3000:3000 clockworklabs/spacetime start

To build from source (useful for unreleased master features), you need the Rust toolchain with the wasm32-unknown-unknown target:

curl https://sh.rustup.rs -sSf | sh

git clone https://github.com/clockworklabs/SpacetimeDB
cd SpacetimeDB
cargo build --locked --release -p spacetimedb-standalone -p spacetimedb-update -p spacetimedb-cli

After building, copy the resulting binaries into place per the platform-specific instructions in the README, then verify with:

spacetime --version

Full documentation, including quickstarts per language, core concepts (tables, reducers, subscriptions, authentication), tutorials, and a CLI/SQL reference, is available at spacetimedb.com/docs.

Frequently asked questions

Share:

Stars
25.1K
Forks
1K
Last commit
20 hours ago
Repository age
3 years
Self-hosted
Yes
Activity score
81/100
View Repository
Ad
Favicon

 

  
 

Similar to SpacetimeDB

Favicon

 

  
 
Favicon

 

  
 
Favicon