Skip to content

Commit 8cd2936

Browse files
authored
Add railway section to the docs (#4904)
# Description of Changes Add documentation for how to deploy on Railway under "Hosting" in the docs https://github.com/user-attachments/assets/b36a7f53-e0db-4fa3-8b0e-65930c71b3a8 # API and ABI breaking changes <!-- If this is an API or ABI breaking change, please apply the corresponding GitHub label. --> # Expected complexity level and risk 1 - just a docs change # Testing Ran the docs locally and verified the page looked good and that the content is correct. See video above.
1 parent 0b30870 commit 8cd2936

2 files changed

Lines changed: 72 additions & 0 deletions

File tree

docs/docs/00300-resources/00000-index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Step-by-step guides for common tasks.
1212

1313
- **Deployment**
1414
- [Deploy to MainCloud](./00100-how-to/00100-deploy/00100-maincloud.md) - Deploy to SpacetimeDB's managed cloud
15+
- [Railway](./00100-how-to/00100-deploy/00300-railway.md) - Deploy SpacetimeDB with the official Railway template
1516
- [Self-Hosting](./00100-how-to/00100-deploy/00200-self-hosting.md) - Run SpacetimeDB on your own infrastructure
1617

1718
- **Database Features**
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: Railway
3+
slug: /how-to/deploy/railway
4+
---
5+
6+
Railway is a hosted platform for deploying infrastructure and application services. If you want to run SpacetimeDB without managing your own VM, the official Railway template is a quick way to get started.
7+
8+
The template deploys the first-party `clockworklabs/spacetime` image, exposes port `3000`, and provisions persistent storage at `/stdb`. Once the service is running, you can publish one or more databases to it with the SpacetimeDB CLI.
9+
10+
## Prerequisites
11+
12+
1. A [Railway account](https://railway.com/)
13+
2. The SpacetimeDB CLI installed: [Install SpacetimeDB](https://spacetimedb.com/install)
14+
3. A SpacetimeDB module project ready to publish
15+
16+
## Step 1: Deploy the Railway template
17+
18+
Open the official deployment template:
19+
20+
[SpacetimeDB Template](https://railway.com/deploy/spacetimedb)
21+
22+
Then:
23+
24+
1. Click **Deploy Now**.
25+
2. Create a new Railway project or choose an existing one.
26+
3. Wait for the deployment to finish.
27+
4. In Railway, open your service and copy its public domain or attach a custom domain.
28+
29+
That domain is the base URL your CLI and clients will use to connect to this SpacetimeDB instance.
30+
31+
## Step 2: Add the Railway deployment to your CLI
32+
33+
Register your Railway deployment as a named server:
34+
35+
```bash
36+
spacetime server add --url https://<your-railway-domain> railway
37+
```
38+
39+
For example:
40+
41+
```bash
42+
spacetime server add --url https://my-railway-app.up.railway.app railway
43+
```
44+
45+
You can optionally verify the connection:
46+
47+
```bash
48+
spacetime server ping railway
49+
```
50+
51+
## Step 3: Publish your database
52+
53+
From your SpacetimeDB project, publish a database to the Railway deployment:
54+
55+
```bash
56+
spacetime publish my-database --server railway
57+
```
58+
59+
To update an existing database later, run the same command again.
60+
61+
## Step 4: Connect clients
62+
63+
After publishing, connect your client to your Railway-hosted database using your Railway domain as the server URI and your database name.
64+
65+
See [Connecting to SpacetimeDB](../../../00200-core-concepts/00600-clients/00300-connection.md) for the current client connection patterns across supported SDKs.
66+
67+
## Notes
68+
69+
- The Railway template sets up the SpacetimeDB server itself, but it does not publish your module for you. You still deploy your database schema and logic with `spacetime publish`.
70+
- A single Railway-hosted SpacetimeDB instance can host multiple databases.
71+
- If you want full control over the host, reverse proxy, and operating system setup, see [Self-hosting](./00200-self-hosting.md).

0 commit comments

Comments
 (0)