skills/concepts/SKILL.md
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.