docs/docs/00300-resources/00100-how-to/00100-deploy/00100-maincloud.md
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import { CppModuleVersionNotice } from "@site/src/components/CppModuleVersionNotice";
Maincloud is SpacetimeDB's fully managed serverless platform. It handles infrastructure, scaling, replication, and backups so you can focus on building your application. Maincloud scales to zero when your database is idle, so you only pay for what you use.
For pricing details, see the pricing page.
spacetime login
This opens a browser window where you sign in with your GitHub account. Once authenticated, your CLI identity is linked to your Maincloud account, and any databases you publish will appear on the web dashboard.
:::tip
If you previously published a database without logging in first, your CLI identity will not be linked to your web account. Run spacetime logout followed by spacetime login to re-authenticate.
:::
After creating your module (see Getting Started), publish it to Maincloud:
spacetime publish my-database --server maincloud
SpacetimeDB compiles your module, uploads it, runs your init reducer (if defined), and outputs the database identity. Save this identity for administrative tasks.
To update an existing module, run the same command. SpacetimeDB hot-swaps the module code without disconnecting clients. See Automatic Migrations for details on schema changes during updates.
To clear all data and start fresh:
spacetime publish my-database --server maincloud --delete-data
To connect your client application to a module running on Maincloud, use https://maincloud.spacetimedb.com as the host URL and your database name as the module name:
DbConnection.builder()
.withUri("https://maincloud.spacetimedb.com")
.withDatabaseName("my-database")
.build();
DbConnection.Builder()
.WithUri("https://maincloud.spacetimedb.com")
.WithDatabaseName("my-database")
.Build();
DbConnection::builder()
.with_uri("https://maincloud.spacetimedb.com")
.with_database_name("my-database")
.build()
.expect("Failed to connect");
auto conn = DbConnection::builder()
.with_uri("https://maincloud.spacetimedb.com")
.with_database_name("my-database")
.build();
After publishing, you can manage your database through the web dashboard at spacetimedb.com.
There are two ways to navigate to your database:
https://spacetimedb.com/my-database or https://spacetimedb.com/@my-username/my-database (replacing my-database with your database name).https://spacetimedb.com/@your-username.The database dashboard gives you access to:
Maincloud databases have two states:
On the Free tier, Maincloud automatically pauses databases after a period of inactivity (no client connections, no reducer calls). A paused database resumes automatically when it receives a connection or request. Startup time is typically less than one second.
On the Pro and Team tiers, databases are never automatically suspended as long as you have pay-as-you-go enabled or have not exceeded your self-set spending limit. If you want to ensure your database is always available, upgrade to the Pro or Team tier.
You can manually pause and resume your database from the web dashboard:
Pausing a database stops all energy usage for that database. This is useful if you want to keep your data but are not actively using the database.
To permanently delete a database and all its data:
spacetime delete my-database --server maincloud
This action cannot be undone.