docs/docs/00200-core-concepts/00100-databases/00300-spacetime-publish.md
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
spacetime publishThis guide covers how to build and publish your SpacetimeDB module.
Before you can publish a module to SpacetimeDB, you need to build it for the appropriate runtime:
Navigate to your module directory (typically spacetimedb/ within your project) and run:
spacetime build
This compiles your module and validates its structure.
:::tip
If you're publishing your module, you don't need to run spacetime build separately - spacetime publish will automatically build your module if needed.
:::
For all build options, see the spacetime build CLI reference.
Once you've built your module, you can publish it to create a new database or update an existing one.
Before publishing, authenticate with SpacetimeDB:
spacetime login
This opens a browser window for authentication. Once complete, your credentials are saved locally.
To publish your module and create a new database:
spacetime publish <DATABASE_NAME>
This command:
init lifecycle reducer (if defined)After publishing, SpacetimeDB outputs your database identity. Save this identity - you'll need it for administrative tasks.
To update a module that's already published:
spacetime publish <DATABASE_NAME>
SpacetimeDB will:
If your update includes breaking changes that cannot be automatically migrated:
spacetime publish --break-clients <DATABASE_NAME>
⚠️ Warning: This will break existing clients that haven't been updated to match your new schema.
If this publish is a major upgrade from 1.x to 2.0, read 1.x to 2.0 Upgrade Notes first.
To completely reset your database and delete all data:
spacetime publish --delete-data <DATABASE_NAME>
⚠️ Warning: This permanently deletes all data in your database!
For all available publishing options and flags, see the spacetime publish CLI reference.
After publishing: