spacetimedb-typescript

Generate typed TypeScript clients for SpacetimeDB modules with WebSocket connections.

25.0k|1.0k|Updated Jun 17, 2023
One-click install
npx skills add https://github.com/clockworklabs/SpacetimeDB --skill spacetimedb-typescript
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: spacetimedb-typescript
Source: https://github.com/clockworklabs/SpacetimeDB/tree/main/skills/spacetimedb-typescript
Command: npx skills add https://github.com/clockworklabs/SpacetimeDB --skill spacetimedb-typescript

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides clear, type-safe guidance and patterns to build robust TypeScript clients that connect directly to SpacetimeDB modules, removing ambiguity about bindings, reducer calls, subscriptions, and data types so developers avoid runtime errors and sync issues.

Core Features & Use Cases

  • Generated module bindings that map server schema to client types for safe table access and reducer invocation.
  • Real-time subscriptions and reactive updates using WebSocket-based connection builders and subscription handles.
  • Correct invocation patterns and data handling including object-style reducer calls, BigInt usage for 64-bit fields, index and view best practices, and explicit transaction usage for procedures.
  • Use case: Build a multiplayer game or collaborative app that synchronizes player state, events, and leaderboards with predictable types and minimal client-side reconciliation.

Quick Start

Connect a TypeScript client to a SpacetimeDB module using the generated module bindings, a WebSocket URI, and an optional token to establish a subscription and load tables.

Frequently Asked Questions about spacetimedb-typescript

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I connect a TypeScript client to SpacetimeDB for real-time data synchronization?

Establish a WebSocket connection to SpacetimeDB using generated module bindings, a WebSocket URI, and an optional token to configure real-time subscriptions and load tables for reactive updates.

What are generated module bindings in SpacetimeDB and when do I need them?

Generated module bindings map your SpacetimeDB server schema to client types, providing type-safe table access and reducer invocation. You need them to remove ambiguity and avoid runtime errors when interacting with database modules.

How do I handle 64-bit fields and reducer calls in a SpacetimeDB TypeScript SDK?

Handle 64-bit fields in the SpacetimeDB TypeScript SDK by using BigInt for numerical values, and invoke reducers using object-style call patterns to ensure correct data handling and explicit transaction usage for procedures.

Can I use the SpacetimeDB TypeScript SDK with server-side JavaScript runtimes?

Yes, the SpacetimeDB TypeScript SDK applies to both frontend and server JavaScript runtimes, enabling real-time subscriptions, table access, reducer calls, views, and scheduled jobs across different execution environments.

What is the best way to build a multiplayer game client with SpacetimeDB and TypeScript?

The best way to build a multiplayer game client with SpacetimeDB and TypeScript is using type-safe generated bindings for WebSocket subscriptions, ensuring predictable player state synchronization and minimal client-side reconciliation.

Why do my SpacetimeDB reducer calls fail when using TypeScript?

SpacetimeDB reducer calls may fail if you do not use object-style invocation patterns or correct BigInt handling for 64-bit fields, leading to type mismatches and runtime sync issues with the server schema.