Skip to main content
Reference engineering Archived 16 min read Updated

docs-how-to

\ How To Guides | SpacetimeDB docs \ \document.documentElement.setAttribute("data-theme","light"),document.documentElement.setAttribute("data-theme-choice","light"),function(){try{const c=new URLSearchParams(window.location.search).entries();for(var[t,e]of c)if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}()
\Version: 2.0.0
\\How To Guides

Step-by-step guides for common tasks.

\
  • Troubleshooting

    \
  • Troubleshooting - Fix common problems with logins, modules and clients
  • App Patterns

    \
  • Pagination - Load a large feed one page at a time with a view that takes the page number and page size
  • Admin and Moderator Roles - Let moderators and admins do what regular users can't, checked in each reducer
  • Send an Email - Queue emails from reducers and send them from a scheduled procedure, with retries
  • Call an External API - Fetch data from a web API on a schedule and store it in a table that clients subscribe to
  • Call an AI Model - Generate text from a procedure without exposing your API key
  • Call an AI Model from a Sidecar - Answer players with a separate program next to your database
  • Seed Initial Data - Fill tables when the database is created, and update them later with an owner-only reducer
  • Store Files in S3 - Let players upload and download files directly to a private bucket, with URLs your module signs
  • Social Features

    \
  • Unique Usernames - Keep names unique and reject offensive ones with a word list and a moderation API
  • Friends or Follow List - Let players follow each other and see their own lists live
  • Chat Rooms and Private DMs - Let players chat in rooms and send direct messages that only the right players receive
  • Typing Indicators - Show who's typing with an event table, without storing anything
  • Unread Counts - Show how many messages each room has that the player hasn't read, and notify them about new ones
  • Multiplayer Games

    \
  • Top 100 Leaderboard - Keep a live top 100 that clients subscribe to
  • Fixed-Rate Game Tick - Run game logic on a schedule
  • Matchmaking Queue - Pair waiting players into matches
  • Skill-Based Matchmaking - Match players of similar skill with OpenSkill
  • Turn-Based Game - Enforce turns and time limits on the server
  • Sync Nearby Players - Send each client only what's near its player
  • Hide Information - Keep tables private and show each player only what they may see
  • Seasonal Leaderboard - Start the leaderboard over each season and keep a hall of fame
  • Develop

    \
  • Unit Testing - Test Rust and TypeScript modules against an in-memory database
  • Logging - Set up logging for debugging
  • Deploy

    \
  • Deploy to MainCloud - Deploy to SpacetimeDB's managed cloud
  • Railway - Deploy SpacetimeDB with the official Railway template
  • Self-Hosting - Run SpacetimeDB on your own infrastructure
  • Azure VMs and Key Rotation - Rotate JWT signing keys on self-hosted servers without breaking spacetime publish
  • Database Features

    \
  • PostgreSQL Compatibility - Connect with PostgreSQL clients
  • Row-Level Security - Fine-grained access control
  • Reject Connections - Control client access
  • Migrate

    \
  • From 1.0 to 2.0 - Update your code for the breaking changes in SpacetimeDB 2.0
  • From Convex - Move an app backend from Convex to a SpacetimeDB module