spacetimedb-reducers
Installation
SKILL.md
Use this skill for reducer implementation and transactional server logic.
Core reducer patterns
Reducers are the transactional entrypoints for table mutation. A successful reducer commits all table changes; a thrown exception, returned error, or panic rolls all of them back.
TypeScript reducer shape:
export const create_user = spacetimedb.reducer(
{ name: t.string(), email: t.string() },
(ctx, { name, email }) => {
if (name === "") throw new Error("Name cannot be empty");
ctx.db.user.insert({ id: 0n, name, email });
},
);
Language-specific signatures: