tools/llm-sequential-upgrade/backends/spacetime.md
Instructions for generating, building, and deploying the SpacetimeDB backend.
spacetime server ping local
If SpacetimeDB is not running, STOP and report the error.
<app-dir>/
backend/spacetimedb/
package.json
tsconfig.json
src/
schema.ts # All tables and indexes
index.ts # All reducers and lifecycle hooks
client/
package.json
vite.config.ts
tsconfig.json
index.html
src/
config.ts # Module name and SpacetimeDB URI
main.tsx # React entry point
App.tsx # Main application component
styles.css # Dark theme styling
module_bindings/ # Auto-generated (Phase 2)
backend/spacetimedb/package.json (use template in "Backend Templates" section below)backend/spacetimedb/tsconfig.json (use template below)backend/spacetimedb/src/schema.ts — all tables and indexesbackend/spacetimedb/src/index.ts — all reducers and lifecycle hookscd <backend-dir> && npm install
spacetime publish chat-app-<timestamp> --module-path <backend-dir>
Module naming: Use the timestamped folder name as the module name (e.g. chat-app-20260330-143000).
spacetime generate --lang typescript --out-dir <client>/src/module_bindings --module-path <backend-dir>
Read the generated bindings to know the exact type names (table names, reducer signatures) before writing client code.
Generate client files using the REAL binding types from Phase 2.
client/package.json (use template below)client/vite.config.ts (use template below)client/tsconfig.json (use template below)client/index.html (use template below)client/src/config.ts — module name and SpacetimeDB URIclient/src/main.tsx — React entry pointclient/src/App.tsx — main application componentclient/src/styles.css — dark theme stylingCRITICAL: Import from ./module_bindings using the REAL generated type names, not guessed ones.
cd <client-dir> && npm install
npx tsc --noEmit # Type-check
npm run build # Full production build
Both must pass. If either fails:
# Kill any existing dev server
npx kill-port 6173 2>/dev/null || true
# Start dev server in background
cd <client-dir> && npm run dev &
Wait for the dev server to be ready (poll http://localhost:6173 up to 30 seconds).
<title> MUST be "SpacetimeDB Chat" (not "Chat App" or anything generic)spacetime publish chat-app-<timestamp> --module-path <backend-dir>
spacetime generate --lang typescript --out-dir <client>/src/module_bindings --module-path <backend-dir>