一键导入
concepts
// Understand SpacetimeDB architecture and core concepts. Use when learning SpacetimeDB or making architectural decisions.
// Understand SpacetimeDB architecture and core concepts. Use when learning SpacetimeDB or making architectural decisions.
SpacetimeDB CLI reference for initializing projects, building modules, publishing databases, querying data, and managing servers
SpacetimeDB C++ server module SDK reference. Use when writing tables, reducers, or module logic in C++.
SpacetimeDB C#/.NET client SDK reference. Use when building C# clients that connect to SpacetimeDB (console, desktop, or any .NET app).
SpacetimeDB C# server module SDK reference. Use when writing tables, reducers, or module logic in C#.
SpacetimeDB Rust server module SDK reference. Use when writing tables, reducers, or module logic in Rust.
SpacetimeDB TypeScript/React client SDK reference. Use when building web clients that connect to SpacetimeDB.
| name | concepts |
| description | Understand SpacetimeDB architecture and core concepts. Use when learning SpacetimeDB or making architectural decisions. |
| license | Apache-2.0 |
| metadata | {"author":"clockworklabs","version":"2.0","role":"shared","language":"all","cursor_globs":"**/*","cursor_always_apply":true} |
SpacetimeDB is a relational database that is also a server. It lets you upload application logic directly into the database via WebAssembly modules, eliminating the traditional web/game server layer entirely.
ctx.sender is the authenticated principal. Never trust identity passed as arguments.spacetime start)spacetime publish)spacetime generate)spacetime logs <db-name>)Organize data by access pattern, not by entity:
Player PlayerState PlayerStats
id <-- player_id player_id
name position_x total_kills
position_y total_deaths
velocity_x play_time
Reducers are transactional functions that modify database state. They run atomically, cannot interact with the outside world, and do not return data to callers. See the language-specific server skills for syntax.
Event tables broadcast reducer-specific data to clients. Rows are never stored in the client cache (count() returns 0, iter() yields nothing); only onInsert callbacks fire.
Subscriptions replicate database rows to clients in real-time.
onInsert, onDelete, onUpdate)Best practices:
Modules are WebAssembly bundles containing application logic that runs inside the database.
ctx.withTx)Server-side modules can be written in: Rust, C#, TypeScript, C++
Lifecycle: Write → Compile → Publish (spacetime publish) → Hot-swap (republish without disconnecting clients)
ctx.sender / ctx.Sender / ctx.sender() for authorization.SpacetimeDB works with many OIDC providers, including SpacetimeAuth (built-in), Auth0, Clerk, Keycloak, Google, and GitHub.